Esempio n. 1
0
    def test_resolve_all_users(self):
        mixer.blend(get_user_model())
        mixer.blend(get_user_model())
        client = JSONWebTokenClient()

        result = client.execute(queries.ALL_USER)
        assert len(result.data.get('allUsers')) == 2, 'Should return all users'
Esempio n. 2
0
    def test_signup_user_and_current_user(self):
        client = JSONWebTokenClient()
        variable = {'email': '*****@*****.**', 'password': '******'}

        result = client.execute(query=queries.SIGNUP_USER, variables=variable)
        tkn1 = result.data.get('tokenAuth')['token']
        assert not result.errors

        variable = {'email': '*****@*****.**', 'password': '******'}
        result = client.execute(queries.TOKEN_AUTH, variables=variable)
        assert result.errors
        variable = {'email': '*****@*****.**', 'password': '******'}
        result = client.execute(queries.TOKEN_AUTH, variables=variable)
        assert result.errors

        variable = {'email': '*****@*****.**', 'password': '******'}
        result = client.execute(queries.TOKEN_AUTH, variables=variable)
        assert result.data.get('tokenAuth')['token'] and not result.errors
        assert tkn1 == result.data.get('tokenAuth')['token']

        result = client.execute(queries.CURRENT_USER)
        assert result.data.get('currentUser') is None

        client.authenticate(
            get_user_model().objects.get(email=variable['email']))
        result = client.execute(queries.CURRENT_USER)
        assert result.data.get('currentUser')['email'] == variable['email']
Esempio n. 3
0
def client():
    return JSONWebTokenClient()
Esempio n. 4
0
    def setup(cls):
        cls.client = JSONWebTokenClient()
        cls.user = mixer.blend(get_user_model())

        cls.client.authenticate(cls.user)
Esempio n. 5
0
 def setup(cls):
     cls.client = JSONWebTokenClient()
     cls.user = AnonymousUser()