def test_defenitely_unpublish_alerted_opinion(self): opinion = PublishableContentFactory(type='OPINION') opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode='W') opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.assertEqual( self.client.login(username=self.user_author.username, password='******'), True) # publish result = self.client.post(reverse('validation:publish-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 302) # login as staff self.assertEqual( self.client.login(username=self.user_staff.username, password='******'), True) alerter = ProfileFactory().user Alert.objects.create( author=alerter, scope='CONTENT', content=opinion, pubdate=datetime.datetime.now(), text="J'ai un probleme avec cette opinion : c'est pas la mienne.") # unpublish opinion result = self.client.post(reverse('validation:ignore-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'operation': 'REMOVE_PUB', }, follow=False) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _('Billet modéré')) # front result = self.client.post(reverse('validation:publish-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 403) # back self.assertTrue(Alert.objects.filter(content=opinion).last().solved) # check alert page is still accessible and our alert is well displayed resp = self.client.get(reverse('pages-alerts')) self.assertEqual(200, resp.status_code) self.assertEqual(0, len(resp.context['alerts'])) self.assertEqual(1, len(resp.context['solved']))
def test_defenitely_unpublish_alerted_opinion(self): opinion = PublishableContentFactory(type='OPINION') opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode='W') opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.assertEqual( self.client.login( username=self.user_author.username, password='******'), True) # publish result = self.client.post( reverse('validation:publish-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 302) # login as staff self.assertEqual( self.client.login( username=self.user_staff.username, password='******'), True) alerter = ProfileFactory().user Alert.objects.create(author=alerter, scope='CONTENT', content=opinion, pubdate=datetime.datetime.now(), text="J'ai un probleme avec cette opinion : c'est pas la mienne.") # unpublish opinion result = self.client.post( reverse('validation:ignore-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'operation': 'REMOVE_PUB', }, follow=False) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _('Billet modéré')) # front result = self.client.post( reverse('validation:publish-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 403) # back self.assertTrue(Alert.objects.filter(content=opinion).last().solved) # check alert page is still accessible and our alert is well displayed resp = self.client.get(reverse('pages-alerts')) self.assertEqual(200, resp.status_code) self.assertEqual(0, len(resp.context['alerts'])) self.assertEqual(1, len(resp.context['solved']))
def test_permanently_unpublish_opinion(self): opinion = PublishableContentFactory(type='OPINION') opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode='W') opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.assertEqual( self.client.login(username=self.user_author.username, password='******'), True) # publish result = self.client.post(reverse('validation:publish-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 302) # login as staff self.assertEqual( self.client.login(username=self.user_staff.username, password='******'), True) # unpublish opinion result = self.client.post(reverse('validation:ignore-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'operation': 'REMOVE_PUB', }, follow=False) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _('Billet modéré')) # front result = self.client.post(reverse('validation:publish-opinion', kwargs={ 'pk': opinion.pk, 'slug': opinion.slug }), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 403) # back
def test_defenitely_unpublish_alerted_opinion(self): opinion = PublishableContentFactory(type="OPINION") opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode="W") opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.client.force_login(self.user_author) # publish result = self.client.post( reverse("validation:publish-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "source": "", "version": opinion_draft.current_version }, follow=False, ) self.assertEqual(result.status_code, 302) # login as staff self.client.force_login(self.user_staff) alerter = ProfileFactory().user Alert.objects.create( author=alerter, scope="CONTENT", content=opinion, pubdate=datetime.datetime.now(), text="J'ai un probleme avec cette opinion : c'est pas la mienne.", ) # unpublish opinion result = self.client.post( reverse("validation:ignore-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "operation": "REMOVE_PUB", }, follow=False, ) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _("Billet modéré")) # front result = self.client.post( reverse("validation:publish-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "source": "", "version": opinion_draft.current_version }, follow=False, ) self.assertEqual(result.status_code, 403) # back self.assertTrue(Alert.objects.filter(content=opinion).last().solved) # check alert page is still accessible and our alert is well displayed resp = self.client.get(reverse("pages-alerts")) self.assertEqual(200, resp.status_code) self.assertEqual(0, len(resp.context["alerts"])) self.assertEqual(1, len(resp.context["solved"]))
def test_permanently_unpublish_opinion(self): opinion = PublishableContentFactory(type='OPINION') opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode='W') opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.assertEqual( self.client.login( username=self.user_author.username, password='******'), True) # publish result = self.client.post( reverse('validation:publish-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 302) # login as staff self.assertEqual( self.client.login( username=self.user_staff.username, password='******'), True) # unpublish opinion result = self.client.post( reverse('validation:ignore-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'operation': 'REMOVE_PUB', }, follow=False) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _('Billet modéré')) # front result = self.client.post( reverse('validation:publish-opinion', kwargs={'pk': opinion.pk, 'slug': opinion.slug}), { 'source': '', 'version': opinion_draft.current_version }, follow=False) self.assertEqual(result.status_code, 403) # back
def test_permanently_unpublish_opinion(self): opinion = PublishableContentFactory(type="OPINION") opinion.authors.add(self.user_author) UserGalleryFactory(gallery=opinion.gallery, user=self.user_author, mode="W") opinion.licence = self.licence opinion.save() opinion_draft = opinion.load_version() ExtractFactory(container=opinion_draft, db_object=opinion) ExtractFactory(container=opinion_draft, db_object=opinion) self.client.force_login(self.user_author) # publish result = self.client.post( reverse("validation:publish-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "source": "", "version": opinion_draft.current_version }, follow=False, ) self.assertEqual(result.status_code, 302) # login as staff self.client.force_login(self.user_staff) # unpublish opinion result = self.client.post( reverse("validation:ignore-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "operation": "REMOVE_PUB", }, follow=False, ) self.assertEqual(result.status_code, 200) # refresh opinion = PublishableContent.objects.get(pk=opinion.pk) # check that the opinion is not published self.assertFalse(opinion.in_public()) # check that it's impossible to publish the opinion again result = self.client.get(opinion.get_absolute_url()) self.assertContains(result, _("Billet modéré")) # front result = self.client.post( reverse("validation:publish-opinion", kwargs={ "pk": opinion.pk, "slug": opinion.slug }), { "source": "", "version": opinion_draft.current_version }, follow=False, ) self.assertEqual(result.status_code, 403) # back
class PublicationFronttest(StaticLiveServerTestCase, TutorialTestMixin, TutorialFrontMixin): @classmethod def setUpClass(cls): super(PublicationFronttest, cls).setUpClass() options = Options() options.headless = True cls.selenium = Firefox(options=options) cls.selenium.implicitly_wait(10) @classmethod def tearDownClass(cls): cls.selenium.quit() super(PublicationFronttest, cls).tearDownClass() def tearDown(self): super().tearDown() self.clean_media_dir() def setUp(self): self.overridden_zds_app = overridden_zds_app # don't build PDF to speed up the tests overridden_zds_app["content"]["build_pdf_when_published"] = False self.staff = StaffProfileFactory().user settings.EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" self.mas = ProfileFactory().user overridden_zds_app["member"]["bot_account"] = self.mas.username self.licence = LicenceFactory() self.subcategory = SubCategoryFactory(category=CategoryFactory()) self.user_author = ProfileFactory().user self.user_staff = StaffProfileFactory().user self.user_guest = ProfileFactory().user self.content = PublishableContentFactory( author_list=[self.user_author], light=False) self.part_published = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) self.ignored_part = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) ExtractFactory(db_object=self.content, container=self.part_published, light=False) ExtractFactory(db_object=self.content, container=self.ignored_part, light=False) def test_partial_publication(self): self.login_author() self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) find_element = self.selenium.find_element_by_css_selector button = WebDriverWait(self.selenium, 20).until( expected_conditions.element_to_be_clickable( (By.CSS_SELECTOR, ".readiness"))) readiness = button.get_attribute("data-is-ready") button.click() self.wait_element_attribute_change((By.CSS_SELECTOR, ".readiness"), "data-is-ready", readiness, 20) self.content = PublishableContent.objects.get(pk=self.content.pk) self.ignored_part = self.content.load_version().children[1] self.assertFalse(self.ignored_part.ready_to_publish, "part should be marked as not ready to publish") self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) button = find_element(".readiness") self.assertNotEqual(readiness, button.get_attribute("data-is-ready"), "part should be marked as not ready to publish") self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.ask_validation() self.logout() self.login_staff() self.take_reservation() self.validate() url = PublishedContent.objects.get( content__pk=self.content.pk).get_absolute_url_online() self.selenium.get(self.live_server_url + url) self.assertRaises( WebDriverException, find_element, 'a[href="{}"]'.format( reverse( "tutorial:view-container", kwargs={ "slug": self.content.slug, "pk": self.content.pk, "container_slug": self.ignored_part.slug }, )), ) def test_collaborative_article_edition_and_editor_persistence(self): selenium = self.selenium find_element = selenium.find_element_by_css_selector author = ProfileFactory() article = PublishableContentFactory(type="ARTICLE", author_list=[author.user]) versioned_article = article.load_version() article.sha_draft = versioned_article.repo_update("article", "", "", update_slug=False) article.save() article_edit_url = reverse("content:edit", args=[article.pk, article.slug]) self.login(author) selenium.execute_script('localStorage.setItem("editor_choice", "new")' ) # we want the new editor selenium.get(self.live_server_url + article_edit_url) intro = find_element("div#div_id_introduction div.CodeMirror") # ActionChains: Support for CodeMirror https://stackoverflow.com/a/48969245/2226755 action_chains = ActionChains(selenium) scrollDriverTo(selenium, 0, 312) action_chains.click(intro).perform() action_chains.send_keys("intro").perform() output = "div#div_id_introduction div.CodeMirror div.CodeMirror-code" self.assertEqual("intro", find_element(output).text) article.sha_draft = versioned_article.repo_update("article", "new intro", "", update_slug=False) article.save() selenium.refresh() self.assertEqual( "new intro", find_element(".md-editor#id_introduction").get_attribute("value")) def test_the_editor_forgets_its_content_on_form_submission(self): selenium = self.selenium find_element = selenium.find_element_by_css_selector author = ProfileFactory() self.login(author) selenium.execute_script('localStorage.setItem("editor_choice", "new")' ) # we want the new editor new_article_url = self.live_server_url + reverse( "content:create-article") selenium.get(new_article_url) WebDriverWait(self.selenium, 10).until( ec.element_to_be_clickable( (By.CSS_SELECTOR, "input[type=checkbox][name=subcategory]"))).click() find_element("#id_title").send_keys("Oulipo") intro = find_element("div#div_id_introduction div.CodeMirror") action_chains = ActionChains(selenium) action_chains.click(intro).perform() action_chains.send_keys( "Le cadavre exquis boira le vin nouveau.").perform() find_element(".content-container button[type=submit]").click() self.assertTrue( WebDriverWait(selenium, 10).until(ec.title_contains(("Oulipo")))) selenium.get(new_article_url) self.assertEqual( "", find_element(".md-editor#id_introduction").get_attribute("value"))
class PublicationFronttest(StaticLiveServerTestCase, TutorialTestMixin, TutorialFrontMixin): @classmethod def setUpClass(cls): super(PublicationFronttest, cls).setUpClass() cls.selenium = WebDriver() cls.selenium.implicitly_wait(10) @classmethod def tearDownClass(cls): cls.selenium.quit() super(PublicationFronttest, cls).tearDownClass() def tearDown(self): super().tearDown() self.clean_media_dir() def setUp(self): self.overridden_zds_app = overridden_zds_app # don't build PDF to speed up the tests overridden_zds_app['content']['build_pdf_when_published'] = False self.staff = StaffProfileFactory().user settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' self.mas = ProfileFactory().user overridden_zds_app['member']['bot_account'] = self.mas.username self.licence = LicenceFactory() self.subcategory = SubCategoryFactory(category=CategoryFactory()) self.user_author = ProfileFactory().user self.user_staff = StaffProfileFactory().user self.user_guest = ProfileFactory().user self.content = PublishableContentFactory( author_list=[self.user_author], light=False) self.part_published = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) self.ignored_part = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) ExtractFactory(db_object=self.content, container=self.part_published, light=False) ExtractFactory(db_object=self.content, container=self.ignored_part, light=False) def test_partial_publication(self): self.login_author() self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) find_element = self.selenium.find_element_by_css_selector button = WebDriverWait(self.selenium, 20).until( expected_conditions.element_to_be_clickable( (By.CSS_SELECTOR, '.readiness'))) readiness = button.get_attribute('data-is-ready') button.click() self.wait_element_attribute_change((By.CSS_SELECTOR, '.readiness'), 'data-is-ready', readiness, 20) self.content = PublishableContent.objects.get(pk=self.content.pk) self.ignored_part = self.content.load_version().children[1] self.assertFalse(self.ignored_part.ready_to_publish, 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) button = find_element('.readiness') self.assertNotEqual(readiness, button.get_attribute('data-is-ready'), 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.ask_validation() self.logout() self.login_staff() self.take_reservation() self.validate() url = PublishedContent.objects.get( content__pk=self.content.pk).get_absolute_url_online() self.selenium.get(self.live_server_url + url) self.assertRaises( WebDriverException, find_element, 'a[href="{}"]'.format( reverse( 'tutorial:view-container', kwargs={ 'slug': self.content.slug, 'pk': self.content.pk, 'container_slug': self.ignored_part.slug }, )), ) def test_collaborative_article_edition_and_editor_persistence(self): selenium = self.selenium find_element = selenium.find_element_by_css_selector author = ProfileFactory() article = PublishableContentFactory(type='ARTICLE', author_list=[author.user]) versioned_article = article.load_version() article.sha_draft = versioned_article.repo_update('article', '', '', update_slug=False) article.save() article_edit_url = reverse('content:edit', args=[article.pk, article.slug]) self.login(author) selenium.get(self.live_server_url + article_edit_url) intro = find_element('.md-editor#id_introduction') intro.send_keys('intro') selenium.refresh() self.assertEqual( 'intro', find_element('.md-editor#id_introduction').get_attribute('value')) article.sha_draft = versioned_article.repo_update('article', 'new intro', '', update_slug=False) article.save() selenium.refresh() self.assertEqual( 'new intro', find_element('.md-editor#id_introduction').get_attribute('value')) def test_the_editor_forgets_its_content_on_form_submission(self): selenium = self.selenium find_element = selenium.find_element_by_css_selector author = ProfileFactory() self.login(author) new_article_url = self.live_server_url + reverse( 'content:create-article') selenium.get(new_article_url) WebDriverWait(self.selenium, 10).until( ec.element_to_be_clickable( (By.CSS_SELECTOR, 'input[type=checkbox][name=subcategory]'))).click() license_select = Select(find_element('#id_licence')) license_select.select_by_index(len(license_select.options) - 1) find_element('#id_title').send_keys('Oulipo') intro = find_element('.md-editor#id_introduction') intro.send_keys('Le cadavre exquis boira le vin nouveau.') find_element('.content-container button[type=submit]').click() self.assertTrue( WebDriverWait(selenium, 10).until(ec.title_contains(('Oulipo')))) selenium.get(new_article_url) self.assertEqual( '', find_element('.md-editor#id_introduction').get_attribute('value'))
class PublicationFronttest(StaticLiveServerTestCase, TutorialTestMixin, TutorialFrontMixin): @classmethod def setUpClass(cls): super(PublicationFronttest, cls).setUpClass() cls.selenium = WebDriver() cls.selenium.implicitly_wait(10) @classmethod def tearDownClass(cls): cls.selenium.quit() super(PublicationFronttest, cls).tearDownClass() def tearDown(self): super().tearDown() self.clean_media_dir() def setUp(self): self.overridden_zds_app = overridden_zds_app # don't build PDF to speed up the tests overridden_zds_app['content']['build_pdf_when_published'] = False self.staff = StaffProfileFactory().user settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' self.mas = ProfileFactory().user overridden_zds_app['member']['bot_account'] = self.mas.username self.licence = LicenceFactory() self.subcategory = SubCategoryFactory() self.user_author = ProfileFactory().user self.user_staff = StaffProfileFactory().user self.user_guest = ProfileFactory().user self.content = PublishableContentFactory(author_list=[self.user_author], light=False) self.part_published = ContainerFactory(db_object=self.content, light=False, parent=self.content.load_version()) self.ignored_part = ContainerFactory(db_object=self.content, light=False, parent=self.content.load_version()) ExtractFactory(db_object=self.content, container=self.part_published, light=False) ExtractFactory(db_object=self.content, container=self.ignored_part, light=False) def test_partial_publication(self): self.login_author() self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) find_element = self.selenium.find_element_by_css_selector button = WebDriverWait(self.selenium, 20)\ .until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, '.readiness'))) readiness = button.get_attribute('data-is-ready') button.click() self.wait_element_attribute_change((By.CSS_SELECTOR, '.readiness'), 'data-is-ready', readiness, 20) self.content = PublishableContent.objects.get(pk=self.content.pk) self.ignored_part = self.content.load_version().children[1] self.assertFalse(self.ignored_part.ready_to_publish, 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) button = find_element('.readiness') self.assertNotEqual(readiness, button.get_attribute('data-is-ready'), 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.ask_validation() self.logout() self.login_staff() self.take_reservation() self.validate() url = PublishedContent.objects.get(content__pk=self.content.pk).get_absolute_url_online() self.selenium.get(self.live_server_url + url) self.assertRaises(WebDriverException, find_element, 'a[href="{}"]'.format( reverse('tutorial:view-container', kwargs={ 'slug': self.content.slug, 'pk': self.content.pk, 'container_slug': self.ignored_part.slug })))
class PublicationFronttest(StaticLiveServerTestCase, TutorialTestMixin, TutorialFrontMixin): @classmethod def setUpClass(cls): super(PublicationFronttest, cls).setUpClass() cls.selenium = WebDriver() cls.selenium.implicitly_wait(10) @classmethod def tearDownClass(cls): cls.selenium.quit() super(PublicationFronttest, cls).tearDownClass() def tearDown(self): super().tearDown() self.clean_media_dir() def setUp(self): self.overridden_zds_app = overridden_zds_app # don't build PDF to speed up the tests overridden_zds_app['content']['build_pdf_when_published'] = False self.staff = StaffProfileFactory().user settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' self.mas = ProfileFactory().user overridden_zds_app['member']['bot_account'] = self.mas.username self.licence = LicenceFactory() self.subcategory = SubCategoryFactory() self.user_author = ProfileFactory().user self.user_staff = StaffProfileFactory().user self.user_guest = ProfileFactory().user self.content = PublishableContentFactory( author_list=[self.user_author], light=False) self.part_published = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) self.ignored_part = ContainerFactory( db_object=self.content, light=False, parent=self.content.load_version()) ExtractFactory(db_object=self.content, container=self.part_published, light=False) ExtractFactory(db_object=self.content, container=self.ignored_part, light=False) def test_partial_publication(self): self.login_author() self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) find_element = self.selenium.find_element_by_css_selector button = WebDriverWait(self.selenium, 20)\ .until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, '.readiness'))) readiness = button.get_attribute('data-is-ready') button.click() self.wait_element_attribute_change((By.CSS_SELECTOR, '.readiness'), 'data-is-ready', readiness, 20) self.content = PublishableContent.objects.get(pk=self.content.pk) self.ignored_part = self.content.load_version().children[1] self.assertFalse(self.ignored_part.ready_to_publish, 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.selenium.get(self.live_server_url + self.ignored_part.get_absolute_url()) button = find_element('.readiness') self.assertNotEqual(readiness, button.get_attribute('data-is-ready'), 'part should be marked as not ready to publish') self.selenium.get(self.live_server_url + self.content.get_absolute_url()) self.ask_validation() self.logout() self.login_staff() self.take_reservation() self.validate() url = PublishedContent.objects.get( content__pk=self.content.pk).get_absolute_url_online() self.selenium.get(self.live_server_url + url) self.assertRaises( WebDriverException, find_element, 'a[href="{}"]'.format( reverse('tutorial:view-container', kwargs={ 'slug': self.content.slug, 'pk': self.content.pk, 'container_slug': self.ignored_part.slug })))