Example #1
0
 def setUp(self):
     self.view = views.UserPostListView
     self.user1 = UserFactory()
     self.user2 = UserFactory()
     self.url = reverse('blog:user-posts',
                        kwargs={'username': self.user1.username})
     self.posts_user1 = PostFactory.create_batch(2, author=self.user1)
     self.request = RequestFactory().get(self.url)
     self.response = self.view.as_view()(self.request,
                                         username=self.user1.username)
def run():
    admin_user = User.objects.get(username="******")
    for cate in Category.objects.all():
        size = random.randint(10, 20)
        PostFactory.create_batch(size, author=admin_user, category=cate)
    print("Posts created.")