mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
add test case
This commit is contained in:
parent
3a984ee206
commit
d477b41d9a
2 changed files with 25 additions and 7 deletions
|
@ -926,13 +926,8 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
self.assertIn('<div class="alert alert-danger">', resp.data.decode("utf-8"))
|
self.assertIn('<div class="alert alert-danger">', resp.data.decode("utf-8"))
|
||||||
|
|
||||||
# test access to the dashboard when it is activated
|
# test access to the dashboard when it is activated
|
||||||
self.app.config["ACTIVATE_ADMIN_DASHBOARD"] = True
|
self.enable_admin()
|
||||||
self.app.config["ADMIN_PASSWORD"] = generate_password_hash("adminpass")
|
resp = self.client.get("/dashboard")
|
||||||
resp = self.client.post(
|
|
||||||
"/admin?goto=%2Fdashboard",
|
|
||||||
data={"admin_password": "adminpass"},
|
|
||||||
follow_redirects=True,
|
|
||||||
)
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"""<thead>
|
"""<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -941,6 +936,20 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
resp.data.decode("utf-8"),
|
resp.data.decode("utf-8"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_dashboard_project_deletion(self):
|
||||||
|
self.post_project("raclette")
|
||||||
|
self.enable_admin()
|
||||||
|
resp = self.client.get("/dashboard")
|
||||||
|
pattern = re.compile(r"<form id=\"delete-project\" [^>]*?action=\"(.*?)\"")
|
||||||
|
match = pattern.search(resp.data.decode("utf-8"))
|
||||||
|
assert match is not None
|
||||||
|
assert match.group(1) is not None
|
||||||
|
|
||||||
|
resp = self.client.post(match.group(1))
|
||||||
|
|
||||||
|
# project removed
|
||||||
|
assert len(models.Project.query.all()) == 0
|
||||||
|
|
||||||
def test_statistics_page(self):
|
def test_statistics_page(self):
|
||||||
self.post_project("raclette")
|
self.post_project("raclette")
|
||||||
response = self.client.get("/raclette/statistics")
|
response = self.client.get("/raclette/statistics")
|
||||||
|
|
|
@ -110,3 +110,12 @@ class IhatemoneyTestCase(BaseTestCase):
|
||||||
resp.status_code,
|
resp.status_code,
|
||||||
f"{url} expected {expected}, got {resp.status_code}",
|
f"{url} expected {expected}, got {resp.status_code}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def enable_admin(self, password="adminpass"):
|
||||||
|
self.app.config["ACTIVATE_ADMIN_DASHBOARD"] = True
|
||||||
|
self.app.config["ADMIN_PASSWORD"] = generate_password_hash(password)
|
||||||
|
return self.client.post(
|
||||||
|
"/admin?goto=%2Fdashboard",
|
||||||
|
data={"admin_password": password},
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue