diff options
| author | Bhavita Bhatt <bbh@odoo.com> | 2019-12-16 10:49:14 +0000 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2020-02-11 15:30:10 +0000 |
| commit | 4e340cc5f0c1fe9de17a2b852de4faf65a33926a (patch) | |
| tree | 036fc88dcebacfe1036ec2ec3942af5989587807 /addons/website/tests/test_page.py | |
| parent | 4e162a4e7559491af651ab8da197fb16a5212bb0 (diff) | |
[IMP] website: improve code for duplicate and new page
in this commit, throw the wizard to enter the new page name, while duplicating
page button and new duplicate page button added in the page properties dialog.
updated the test case related to duplicate page along with duplicate menu
consideration.
task-2088546
closes #40085
Co-authored-by: jpr-odoo <jpr@openerp.com>
Diffstat (limited to 'addons/website/tests/test_page.py')
| -rw-r--r-- | addons/website/tests/test_page.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/addons/website/tests/test_page.py b/addons/website/tests/test_page.py index 09f39074c89..8bcda96f7e2 100644 --- a/addons/website/tests/test_page.py +++ b/addons/website/tests/test_page.py @@ -60,7 +60,7 @@ class TestPage(common.TransactionCase): total_pages = Page.search_count([]) total_menus = Menu.search_count([]) # Copying a specific page should create a new page with an unique URL (suffixed by -X) - Page.clone_page(self.page_specific.id, True) + Page.clone_page(self.page_specific.id, clone_menu=True) cloned_page = Page.search([('url', '=', '/page_specific-1')]) cloned_menu = Menu.search([('url', '=', '/page_specific-1')]) self.assertEqual(len(cloned_page), 1, "A page with an URL /page_specific-1 should've been created") @@ -69,19 +69,27 @@ class TestPage(common.TransactionCase): self.assertEqual(len(cloned_menu), 1, "A specific page (with a menu) being cloned should have it's menu also cloned") self.assertEqual(cloned_menu.page_id, cloned_page, "The new cloned menu and the new cloned page should be linked (m2o)") self.assertEqual(Menu.search_count([]), total_menus + 1, "Should have cloned the page menu") + Page.clone_page(self.page_specific.id, page_name="about-us", clone_menu=True) + cloned_page_about_us = Page.search([('url', '=', '/about-us')]) + cloned_menu_about_us = Menu.search([('url', '=', '/about-us')]) + self.assertEqual(len(cloned_page_about_us), 1, "A page with an URL /about-us should've been created") + self.assertEqual(len(cloned_menu_about_us), 1, "A specific page (with a menu) being cloned should have it's menu also cloned") + self.assertEqual(cloned_menu_about_us.page_id, cloned_page_about_us, "The new cloned menu and the new cloned page should be linked (m2o)") + # It should also copy its menu with new url/name/page_id (if the page has a menu) + self.assertEqual(Menu.search_count([]), total_menus + 2, "Should have cloned the page menu") total_pages = Page.search_count([]) total_menus = Menu.search_count([]) # Copying a generic page should create a specific page with same URL - Page.clone_page(self.page_1.id, True) + Page.clone_page(self.page_1.id, clone_menu=True) cloned_generic_page = Page.search([('url', '=', '/page_1'), ('id', '!=', self.page_1.id), ('website_id', '!=', False)]) self.assertEqual(len(cloned_generic_page), 1, "A generic page being cloned should create a specific one for the current website") self.assertEqual(cloned_generic_page.url, self.page_1.url, "The URL of the cloned specific page should be the same as the generic page it has been cloned from") self.assertEqual(Page.search_count([]), total_pages + 1, "Should have cloned the generic page as a specific page for this website") self.assertEqual(Menu.search_count([]), total_menus, "It should not create a new menu as the generic page's menu belong to another website") # Except if the URL already exists for this website (its the case now that we already cloned it once) - Page.clone_page(self.page_1.id, True) + Page.clone_page(self.page_1.id, clone_menu=True) cloned_generic_page_2 = Page.search([('url', '=', '/page_1-1'), ('id', '!=', self.page_1.id)]) self.assertEqual(len(cloned_generic_page_2), 1, "A generic page being cloned should create a specific page with a new URL if there is already a specific page with that URL") |
