What are 'rf' and 'user_context' parameters and when are they assigned?
import pytest
from rest_framework import status
from rest_framework.reverse import reverse
from request_helper import pytest_request
@pytest.mark.urls(urls='api.urls')
@pytest.mark.django_db
def test_user_name_check_200(rf, users_context):
data = {
'username': 'test_jay_2'
}
url = reverse(viewname="users-check")
response = pytest_request(rf,
method='get',
url=url,
user=None,
data=data)
assert response.status_code == status.HTTP_200_OK
Both are
pytest
fixtures (read about fixtures here: About fixtures).rf
is defined inpytest-django
(reference); aRequestFactory
instance will be automatically injected for therf
argument in test.users_context
is a fixture defined somewhere in your test project; search for something likein project code.