49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
def test_pages_require_login(client):
|
|
for path in ("/", "/buchungen", "/import", "/planung"):
|
|
r = client.get(path, follow_redirects=False)
|
|
assert r.status_code in (302, 303), path
|
|
assert r.headers["location"] == "/login"
|
|
|
|
|
|
def test_pages_render_after_login(client):
|
|
client.post("/login", data={"username": "admin", "password": "geheim"})
|
|
for path in ("/", "/buchungen", "/import", "/planung"):
|
|
r = client.get(path)
|
|
assert r.status_code == 200
|
|
assert "Finanzberatung" in r.text
|
|
|
|
|
|
def test_import_page_has_dropzone_and_list(client):
|
|
client.post("/login", data={"username": "admin", "password": "geheim"})
|
|
r = client.get("/import")
|
|
assert r.status_code == 200
|
|
assert 'id="dropzone"' in r.text
|
|
assert 'id="imports"' in r.text
|
|
|
|
|
|
def test_import_list_fragment_requires_login(client):
|
|
r = client.get("/import/list", follow_redirects=False)
|
|
assert r.status_code in (302, 303)
|
|
|
|
|
|
def test_import_list_fragment_renders_after_login(client):
|
|
client.post("/login", data={"username": "admin", "password": "geheim"})
|
|
r = client.get("/import/list")
|
|
assert r.status_code == 200
|
|
assert "Noch keine Imports" in r.text
|
|
|
|
|
|
def test_version_visible(client):
|
|
r = client.get("/api/version", headers={"Authorization": "Bearer test-key"})
|
|
assert r.status_code == 200 and r.json()["version"] == "0.2.0"
|
|
client.post("/login", data={"username": "admin", "password": "geheim"})
|
|
assert "v0.2.0" in client.get("/").text
|
|
|
|
|
|
def test_planning_page_has_all_sections(client):
|
|
client.post("/login", data={"username": "admin", "password": "geheim"})
|
|
r = client.get("/planung")
|
|
assert r.status_code == 200
|
|
for heading in ("Wiederkehrende Posten", "Einmalposten", "Kredite", "Szenarien"):
|
|
assert heading in r.text
|