Пример #1
0
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)),
        ]),
    }
Пример #2
0
    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()
Пример #3
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.post = PostFactory()
     cls.user = UserFactory(is_active=True)
     cls.url = reverse('posts:like_toggle')
Пример #4
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.user = UserFactory(is_active=True)
     cls.url = reverse('posts:base_view')
Пример #5
0
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
Пример #6
0
 def setUp(self):
     self.user = UserFactory(username='******', email='*****@*****.**')
     self.form = CustomUserCreationForm
Пример #7
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.user = UserFactory()
     cls.url = reverse('users:signin')
     cls.logout = reverse('users:logout')
Пример #8
0
 def setUp(self):
     self.user = UserFactory(username='******', email='*****@*****.**', password=12121212)
     self.form = CustomAuthenticationForm
Пример #9
0
def user() -> settings.AUTH_USER_MODEL:
    return UserFactory()