*I am trying to add a token to graphene-django headers using pytest. But
It always return that user is anonymous as shown at the end but it
should return user as token is added in fixture@pytest.fixture def
client_query(client): def func(*args, **kwargs): return
graphql_query(*args, **kwargs, client=client) return func @pytest.fixture
def create_candidate(candidate_factory): candidate = [] for _ in range(5):
can = candidate_factory.create() token, __ =
Token.objects.get_or_create(user=can.user) candidate.append(can) return
candidate **This is the test** @pytest.mark.django_db def
test_get_login_candidate(client_query, create_candidate): headers =
{"Authorization": f"Token {create_candidate[0].user.auth_token}"} response
= client_query( """ query { loginCandidate{ id, } } """, headers=headers, )
result = json.loads(response.content) print(result) This is the output
{'errors': [{'message': "'AnonymousUser' object is not iterable",
'locations': [{'line': 3, 'column': 11}], 'path': ['loginCandidate']}],
'data': {'loginCandidate': None}}*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGv3YND402MKNs6w2iFxEoHsMdMBhOwAKLtZy%3DQ2gZ6h9D-%2Bbw%40mail.gmail.com.

Reply via email to