Esempio n. 1
0
 def test_cannot_be_cleaned_if_it_is_not_associated_with_a_user_and_an_anonymous_user(
         self):
     # Run & check
     with pytest.raises(ValidationError):
         post = PostFactory.build(topic=self.topic,
                                  poster=self.u1,
                                  anonymous_key='1234')
         post.clean()
Esempio n. 2
0
 def test_cannot_be_cleaned_if_the_anonymous_poster_username_is_not_specified(
         self):
     # Run & check
     with pytest.raises(ValidationError):
         post = PostFactory.build(topic=self.topic,
                                  poster=None,
                                  anonymous_key='1234')
         post.clean()
Esempio n. 3
0
 def test_save_cannot_trigger_the_update_of_the_member_posts_count_if_the_related_post_is_not_approved(self):
     # Setup
     post = PostFactory.build(topic=self.topic, poster=self.u1, approved=False)
     profile = ForumProfile.objects.get(user=self.u1)
     initial_posts_count = profile.posts_count
     # Run
     post.save()
     # Check
     profile.refresh_from_db()
     assert profile.posts_count == initial_posts_count
Esempio n. 4
0
 def test_save_cannot_trigger_the_update_of_the_member_posts_count_if_the_related_post_is_not_approved(self):  # noqa
     # Setup
     post = PostFactory.build(topic=self.topic, poster=self.u1, approved=False)
     profile = ForumProfile.objects.get(user=self.u1)
     initial_posts_count = profile.posts_count
     # Run
     post.save()
     # Check
     profile.refresh_from_db()
     assert profile.posts_count == initial_posts_count
Esempio n. 5
0
 def test_save_triggers_the_update_of_the_member_posts_count_if_the_related_post_is_approved(self):
     # Setup
     post = PostFactory.build(topic=self.topic, poster=self.u1)
     profile = ForumProfile.objects.get(user=self.u1)
     initial_posts_count = profile.posts_count
     # Run
     post.save()
     # Check
     profile = refresh(profile)
     assert profile.posts_count == initial_posts_count + 1
Esempio n. 6
0
 def test_cannot_be_cleaned_if_the_anonymous_poster_username_is_not_specified(self):
     # Run & check
     with pytest.raises(ValidationError):
         post = PostFactory.build(topic=self.topic, poster=None, anonymous_key='1234')
         post.clean()
Esempio n. 7
0
 def test_cannot_be_cleaned_if_it_is_not_associated_with_a_user_and_an_anonymous_user(self):
     # Run & check
     with pytest.raises(ValidationError):
         post = PostFactory.build(topic=self.topic, poster=self.u1, anonymous_key='1234')
         post.clean()