예제 #1
0
파일: tests.py 프로젝트: geihar/mini_blog
    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)
예제 #2
0
    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)
예제 #3
0
파일: tests.py 프로젝트: geihar/mini_blog
    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)
예제 #4
0
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]
예제 #5
0
def backgrond(context):
    row = context.table[0]
    user = UserFactory(id=row['id'], username=row['username'])
예제 #6
0
    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
예제 #7
0
 def setUp(self):
     self.superuser = UserFactory(is_staff=True, is_superuser=True)
     self.nomaluser = UserFactory()
예제 #8
0
    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)