diff --git a/tests/test_login.py b/tests/test_login.py
index 4a1efb1..dd0f362 100644
--- a/tests/test_login.py
+++ b/tests/test_login.py
@@ -1,3 +1,4 @@
+import pytest
import re
import requests
@@ -5,7 +6,7 @@ import requests
URL = 'http://127.0.0.1:80'
-def test_login_page():
+def test_accessing_login_page():
r = requests.get(URL, allow_redirects=True)
assert r.status_code == 200
@@ -15,25 +16,30 @@ def test_login_page():
assert 'Username' in r.text
-def test_login():
- csrf = ''
+def test_logging_in():
client = requests.session()
r = client.get(URL, allow_redirects=True)
jar = r.cookies
- csrf_match = re.search('', r.text)
+
+ # get csrf token
+ csrf_match = re.search(
+ '',
+ r.text
+ )
+
if csrf_match:
csrf = csrf_match.group(1)
else:
- print("csrf not matched")
+ # if there is no csrf token the test will fail
+ pytest.fail('csrf not matched')
data = {
'_username': 'wallabag',
'_password': 'wallabag',
- '_csrf_token' : csrf
+ '_csrf_token': csrf
}
r = client.post(URL + '/login_check', cookies=jar, data=data)
- print(r.text)
assert r.status_code == 200
assert '/unread/list' in r.text
assert '/starred/list' in r.text