def create_test_page(model, parent=None, title='Test page', path='1111', depth=0, theme=None): if not theme: theme = create_test_theme() if PHEImage.objects.count() == 0: create_default_test_image(id=1) site = Site.objects.first() if not site.site_name: site.site_name = 'test' site.save() site_settings = SiteSettings.objects.filter(site_id=site.id).first() if not site_settings: site_settings = SiteSettings(site_id=site.id) site_settings.menu = create_test_menu() site_settings.save() if parent is None: parent = site.root_page page = model(title=title, path=path, depth=depth, page_theme=theme, live=True) parent.add_child(instance=page) page.save_revision().publish() return page
def create_test_recipe_page(title='Test Recipe page', path='1111', depth=0, theme=None): if not theme: theme = create_test_theme() if PHEImage.objects.count() == 0: create_default_test_image(id=1) site = Site.objects.first() if not site.site_name: site.site_name = 'oneyoutest' site.save() site_settings = SiteSettings.objects.filter(site_id=site.id).first() if not site_settings: site_settings = SiteSettings(site_id=site.id) site_settings.menu = create_test_menu() site_settings.save() root_page = site.root_page page = RecipePage(title=title, path=path, depth=depth, theme=theme) root_page.add_child(instance=page) page.save_revision().publish() return page
def test_get_site_by_id_or_uuid(self): # invalid customsite self.assertEquals(get_site_by_id_or_uuid('12'), None) # invalid uuid site = Site.objects.first() site_settings = SiteSettings(site_id=site.id, uid='test') site_settings.save() self.assertEquals(get_site_by_id_or_uuid('test'), site_settings) self.assertEquals(get_site_by_id_or_uuid('test1'), None) #correct self.assertEquals(get_site_by_id_or_uuid(str(site_settings.id)), site_settings)