From 110281ce0a17fbb32e3788ef262656816d9349f0 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Sun, 17 Oct 2021 23:27:53 -0600 Subject: [PATCH] fixed various typos and variable name changes --- flaskfdx/auth.py | 6 +++--- flaskfdx/templates/auth/login.html | 2 -- tests/conftest.py | 4 ++-- tests/test_auth.py | 20 ++++++++++---------- tests/test_factory.py | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/flaskfdx/auth.py b/flaskfdx/auth.py index f6cafb7..74c22e4 100644 --- a/flaskfdx/auth.py +++ b/flaskfdx/auth.py @@ -19,7 +19,7 @@ def register(): error = None if not userid: - error = 'Username if required.' + error = 'Userid is required.' elif not email: error = 'Email is required.' elif not password: @@ -53,9 +53,9 @@ def login(): ).fetchone() if user is None: - error = 'Incorrect username.' + error = 'Userid or Password incorrect.' elif not check_password_hash(user['password'], password): - error = 'Incorrect password.' + error = 'Userid or Password incorrect.' if error is None: session.clear() diff --git a/flaskfdx/templates/auth/login.html b/flaskfdx/templates/auth/login.html index 8795ffa..cd174bc 100644 --- a/flaskfdx/templates/auth/login.html +++ b/flaskfdx/templates/auth/login.html @@ -8,8 +8,6 @@
- - diff --git a/tests/conftest.py b/tests/conftest.py index 646053c..6057d16 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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): diff --git a/tests/test_auth.py b/tests/test_auth.py index fb9c124..3577516 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -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) diff --git a/tests/test_factory.py b/tests/test_factory.py index 65aa988..0d20f36 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -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!'