示例#1
0
 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()
示例#2
0
    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',
        )
示例#3
0
 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)
示例#4
0
 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())
示例#5
0
    def setUp(self):

        self.user1 = UserFactory(username='******')
        self.user2 = UserFactory(username='******')
        self.post = PostFactory(user=self.user1, title='Velocità con #animato')
示例#6
0
    def setUp(self) -> None:
        from django.contrib.auth.models import User

        self.user: User = UserFactory(username='******')
示例#7
0
    def setUp(self):

        self.user = UserFactory(username='******')
        self.post = PostFactory(user=self.user, title='Looking for #animato')
示例#8
0
 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)
示例#9
0
 def setUp(self):
     self.client = Client()
     self.user = UserFactory()
     self.comment = CommentForPostFactory(user=self.user)
     self.post = PostFactory(user=self.user)
示例#10
0
 def setUp(self) -> None:
     self.user1: User = UserFactory(username='******')
     self.user2: User = UserFactory(username='******')
     self.client = Client()