import json
from app.common.tests import TestBase

class LoginTest(TestBase):
    def test_login_user(self):
        # create user
        self.create_user()

        # loging with user
        data_json = json.dumps(dict(username='admin', password='<PASSWORD>'))
        rv = self.app.post('/api/v1/login', data=data_json, content_type='application/json')
        assert "access_token" in str(rv.data)

    def test_login_user_wrong_pass(self):
        # create user
        self.create_user()

        # loging with user
        data_json = json.dumps(dict(username='admin', password='<PASSWORD>'))
        rv = self.app.post('/api/v1/login', data=data_json, content_type='application/json')
        assert "access_token" not in str(rv.data)

import json
from app.common.tests import TestBase

class LoginTest(TestBase):
    def test_login_user(self):
        # create user
        self.create_user()

        # loging with user
        data_json = json.dumps(dict(username='admin', password='<PASSWORD>'))
        rv = self.app.post('/api/v1/login', data=data_json, content_type='application/json')
        assert "access_token" in str(rv.data)

    def test_login_user_wrong_pass(self):
        # create user
        self.create_user()

        # loging with user
        data_json = json.dumps(dict(username='admin', password='<PASSWORD>'))
        rv = self.app.post('/api/v1/login', data=data_json, content_type='application/json')
        assert "access_token" not in str(rv.data)

# create user # loging with user # create user # loging with user