mirror of
https://github.com/leaders-of-digital-9-task/backend.git
synced 2024-11-15 05:56:34 +03:00
31 lines
806 B
Python
31 lines
806 B
Python
|
from django.test import RequestFactory
|
||
|
|
||
|
from image_markuper.users.api.views import UserViewSet
|
||
|
from image_markuper.users.models import User
|
||
|
|
||
|
|
||
|
class TestUserViewSet:
|
||
|
def test_get_queryset(self, user: User, rf: RequestFactory):
|
||
|
view = UserViewSet()
|
||
|
request = rf.get("/fake-url/")
|
||
|
request.user = user
|
||
|
|
||
|
view.request = request
|
||
|
|
||
|
assert user in view.get_queryset()
|
||
|
|
||
|
def test_me(self, user: User, rf: RequestFactory):
|
||
|
view = UserViewSet()
|
||
|
request = rf.get("/fake-url/")
|
||
|
request.user = user
|
||
|
|
||
|
view.request = request
|
||
|
|
||
|
response = view.me(request)
|
||
|
|
||
|
assert response.data == {
|
||
|
"username": user.username,
|
||
|
"name": user.name,
|
||
|
"url": f"http://testserver/api/users/{user.username}/",
|
||
|
}
|