def setUp(self): self.user_1 = UserFactory() self.user_2 = UserFactory() for i in range(15): user = self.user_1 if i % 2 == 0 else self.user_2 published = True if i % 2 == 0 else False PostFactory(published=published, author=user)
def test_can_get_user_posts(self): user1 = UserFactory() user2 = UserFactory() post1 = PostFactory(author=user1) PostFactory(author=user2) post3 = PostFactory(author=user1) user1_posts = user1.blog_posts.all() self.assertEqual(len(user1_posts), 2) self.assertIn(post1, user1_posts) self.assertIn(post3, user1_posts)
def setUp(self): self.user_1 = UserFactory() self.user_2 = UserFactory() for i in range(10): user = self.user_1 if i % 2 == 0 else self.user_2 published = True if i % 2 == 0 else False post = PostFactory(published=published, author=user, tags=(self.tag_1, )) print(post.tags)
def step_impl(context): posts = [PostFactory(title=row['title'], slug=row['slug'], author=UserFactory(username=row['author']), body=row['body']) for row in context.table]
def backgrond(context): row = context.table[0] user = UserFactory(id=row['id'], username=row['username'])
def setUp(self): self.superuser = UserFactory(is_staff=True, is_superuser=True) self.nomaluser = UserFactory() self.published_post = PostFactory() # pk = 1 self.non_published_post = PostFactory(published_at=None) # pk = 2
def setUp(self): self.superuser = UserFactory(is_staff=True, is_superuser=True) self.nomaluser = UserFactory()
def test_add_user(self): self.user = UserFactory() user = User.objects.get(id=self.user.id) self.assertEqual(user.first_name, self.user.first_name)