def setUp(self) -> None: self.user_harry = UserFactory(username='******') self.user_hermione = UserFactory(username='******') self.post = PostFactory(user=self.user_harry, status='published', title='Velocità con #animato') self.client = Client()
def setUp(self): from dillo.models.jobs import Job self.user = UserFactory() self.job = Job.objects.create( user=self.user, company='Minstry of Magic', city='London', country='UK', title='Minister of Magic', description='Plain regular description', url_apply='https://ministry.magic', )
def test_comment_delete(self): comment_delete_url = reverse('comment_delete', kwargs={'comment_id': self.comment.id}) # Create another user other_user = UserFactory() self.client.force_login(other_user) response = self.client.post(comment_delete_url) # Deleting the post is not allowed, because the post belongs to another user self.assertEqual(response.status_code, 422) # Log in the user who create the post self.client.force_login(self.user) response = self.client.post(comment_delete_url) # Deletion is successful self.assertEqual(response.status_code, 200)
def test_report_post(self): report_content_url = reverse( 'report_content', kwargs={'content_type_id': self.post.content_type_id, 'object_id': self.post.id}, ) # Ensure that the view is not available if anonymous response = self.client.get(report_content_url) self.assertEqual(response.status_code, 302) self.assertEqual(0, ContentReports.objects.count()) random_user = UserFactory() # Log in the user self.client.force_login(random_user) # Create a Post self.client.post(report_content_url, {'reason': 'inappropriate'}) self.assertEqual(1, ContentReports.objects.count())
def setUp(self): self.user1 = UserFactory(username='******') self.user2 = UserFactory(username='******') self.post = PostFactory(user=self.user1, title='Velocità con #animato')
def setUp(self) -> None: from django.contrib.auth.models import User self.user: User = UserFactory(username='******')
def setUp(self): self.user = UserFactory(username='******') self.post = PostFactory(user=self.user, title='Looking for #animato')
def setUp(self): self.client = Client() self.user = UserFactory(username='******') self.post_title = 'Velocità con #animato' self.post = Post.objects.get(pk=PostFactory(user=self.user, title=self.post_title).pk)
def setUp(self): self.client = Client() self.user = UserFactory() self.comment = CommentForPostFactory(user=self.user) self.post = PostFactory(user=self.user)
def setUp(self) -> None: self.user1: User = UserFactory(username='******') self.user2: User = UserFactory(username='******') self.client = Client()