Exemple #1
0
 def test_publication_and_attributes_consistency(self):
     pubdate = datetime.now() - timedelta(days=1)
     article = PublishedContentFactory(type="ARTICLE",
                                       author_list=[self.user_author])
     public_version = article.public_version
     public_version.publication_date = pubdate
     public_version.save()
     # everything must come from database to have good datetime comparison
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     old_date = article.public_version.publication_date
     old_title = article.public_version.title()
     old_description = article.public_version.description()
     article.licence = LicenceFactory()
     article.save()
     self.assertEqual(
         self.client.login(username=self.user_author.username,
                           password="******"), True)
     self.client.post(
         reverse("content:edit", args=[article.pk, article.slug]),
         {
             "title": old_title + "bla",
             "description": old_description + "bla",
             "type": "ARTICLE",
             "licence": article.licence.pk,
             "subcategory": SubCategoryFactory().pk,
             "last_hash": article.sha_draft,
         },
     )
     article = PublishableContent.objects.prefetch_related(
         "public_version").get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_title, article.public_version.title())
     self.assertEqual(old_description, article.public_version.description())
     self.assertEqual(old_date, article.public_version.publication_date)
     publish_content(article, article.load_version(), False)
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_date, article.public_version.publication_date)
     self.assertNotEqual(old_date, article.public_version.update_date)
Exemple #2
0
 def test_publication_and_attributes_consistency(self):
     pubdate = datetime.now() - timedelta(days=1)
     article = PublishedContentFactory(type='ARTICLE',
                                       author_list=[self.user_author])
     public_version = article.public_version
     public_version.publication_date = pubdate
     public_version.save()
     # everything must come from database to have good datetime comparison
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     old_date = article.public_version.publication_date
     old_title = article.public_version.title()
     old_description = article.public_version.description()
     article.licence = LicenceFactory()
     article.save()
     self.assertEqual(
         self.client.login(username=self.user_author.username,
                           password='******'), True)
     self.client.post(
         reverse('content:edit', args=[article.pk, article.slug]), {
             'title': old_title + 'bla',
             'description': old_description + 'bla',
             'type': 'ARTICLE',
             'licence': article.licence.pk,
             'subcategory': SubCategoryFactory().pk,
             'last_hash': article.sha_draft
         })
     article = PublishableContent.objects.prefetch_related(
         'public_version').get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_title, article.public_version.title())
     self.assertEqual(old_description, article.public_version.description())
     self.assertEqual(old_date, article.public_version.publication_date)
     publish_content(article, article.load_version(), False)
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_date, article.public_version.publication_date)
     self.assertNotEqual(old_date, article.public_version.update_date)
Exemple #3
0
 def test_publication_and_attributes_consistency(self):
     pubdate = datetime.now() - timedelta(days=1)
     article = PublishedContentFactory(type='ARTICLE', author_list=[self.user_author])
     public_version = article.public_version
     public_version.publication_date = pubdate
     public_version.save()
     # everything must come from database to have good datetime comparison
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     old_date = article.public_version.publication_date
     old_title = article.public_version.title()
     old_description = article.public_version.description()
     article.licence = LicenceFactory()
     article.save()
     self.assertEqual(
         self.client.login(
             username=self.user_author.username,
             password='******'),
         True)
     self.client.post(reverse('content:edit', args=[article.pk, article.slug]), {
         'title': old_title + 'bla',
         'description': old_description + 'bla',
         'type': 'ARTICLE',
         'licence': article.licence.pk,
         'subcategory': SubCategoryFactory().pk,
         'last_hash': article.sha_draft
     })
     article = PublishableContent.objects.prefetch_related('public_version').get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_title, article.public_version.title())
     self.assertEqual(old_description, article.public_version.description())
     self.assertEqual(old_date, article.public_version.publication_date)
     publish_content(article, article.load_version(), False)
     article = PublishableContent.objects.get(pk=article.pk)
     article.public_version.load_public_version()
     self.assertEqual(old_date, article.public_version.publication_date)
     self.assertNotEqual(old_date, article.public_version.update_date)