def test_videoviewset_handle_request(rf): """Test VideoViewSet can handle a simple retrieve.""" video = VideoFactory() request = rf.get('/') user = UserFactory() force_authenticate(request, user=user) view = VideoViewSet.as_view({'get': 'retrieve'}) response = view(request, pk=video.id) data = response.data assert data == { 'asset': OrderedDict([ ('type', 'assets'), ('id', str(video.asset_id)), ]), 'session': OrderedDict([ ('type', 'sessions'), ('id', str(video.session_id)), ]), }
def setUp(cls): cls.client = Client() cls.user = UserFactory(is_active=True) cls.url = reverse('posts:base_view') cls.pr1 = PostFactory() LikeFactory.create_batch(2, post=cls.pr1) CommentFactory.create_batch(2, post=cls.pr1) cls.pr2 = PostFactory() LikeFactory.create_batch(2, post=cls.pr2) CommentFactory.create_batch(2, post=cls.pr2) cls.pr3 = PostFactory() LikeFactory.create_batch(2, post=cls.pr3) cls.pr4 = PostFactory() CommentFactory.create_batch(2, post=cls.pr4) cls.pr5 = PostFactory()
def setUpTestData(cls): cls.client = Client() cls.post = PostFactory() cls.user = UserFactory(is_active=True) cls.url = reverse('posts:like_toggle')
def setUpTestData(cls): cls.client = Client() cls.user = UserFactory(is_active=True) cls.url = reverse('posts:base_view')
def test_get_user_without_me(): """Test that get_user uses pk as is if it's not me.""" user = UserFactory() assert get_user(None, {'user_pk': user.pk}) == user
def setUp(self): self.user = UserFactory(username='******', email='*****@*****.**') self.form = CustomUserCreationForm
def setUpTestData(cls): cls.client = Client() cls.user = UserFactory() cls.url = reverse('users:signin') cls.logout = reverse('users:logout')
def setUp(self): self.user = UserFactory(username='******', email='*****@*****.**', password=12121212) self.form = CustomAuthenticationForm
def user() -> settings.AUTH_USER_MODEL: return UserFactory()