fixed various typos and variable name changes

This commit is contained in:
2021-10-17 23:27:53 -06:00
parent e4c051b8c2
commit 110281ce0a
5 changed files with 16 additions and 18 deletions
+2 -2
View File
@@ -38,10 +38,10 @@ class AuthActions(object):
def __init__(self, client):
self._client = client
def login(self, username='test', password='test'):
def login(self, username='test', email='a@.c', password='test'):
return self._client.post(
'auth/login',
data={'username': username, 'password': password}
data={'userid': username, 'email': email, 'password': password}
)
def logout(self):
+10 -10
View File
@@ -7,29 +7,29 @@ def test_register(client, app):
response = client.post(
'auth/register', data={'userid': 'a', 'email': 'a@b.c', 'password': 'a'}
)
assert 'http://localhost/auth/login' == response.headers['Location']
assert 'http://localhost/auth/login' == response.headers['Path']
with app.app_context():
assert get_db().execute(
"SELECT * FROM users WHERE userid = 'a'",
).fetchone() is not None
@pytest.mark.parametrize(('userid', 'password', 'message'), (
('', '', b'Userid is required.'),
('a', '', b'Password is required.'),
('test', 'test', b'already registered'),
@pytest.mark.parametrize(('userid', 'email', 'password', 'message'), (
('', '', '', b'Userid is required.'),
('a', 'a@b.c', '', b'Password is required.'),
('test', 'test', 'test', b'already registered'),
))
def test_register_validate_input(client, userid, password, message):
def test_register_validate_input(client, userid, email, password, message):
response = client.post(
'/auth/register',
data={'userid': userid, 'password': password}
data={'userid': userid, 'email': email, 'password': password}
)
assert message in response.data
def test_login(client, auth):
assert client.get('/auth/login').status_code == 200
response = auth.login()
assert response.headers['Location'] == 'http://localhost/'
assert response.headers['Path'] == 'http://localhost/'
with client:
client.get('/')
@@ -37,8 +37,8 @@ def test_login(client, auth):
assert g.user['userid'] == 'test'
@pytest.mark.parametrize(('userid', 'password', 'message'), (
('a', 'test', b'Incorrect userid'),
('test', 'a', b'Incorrect password.'),
('a', 'test', b'Userid or Password incorrect.'),
('test', 'a', b'Userid or Password incorrect.'),
))
def test_login_validate_input(auth, userid, password, message):
response = auth.login(userid, password)
+1 -1
View File
@@ -6,4 +6,4 @@ def test_config():
def test_hello(client):
response = client.get('/hello')
assert response.data == b'Hello World!'
assert response.data == b'Hello, World!'