Added the test_editor test to the AccountTestCase test case.

This commit is contained in:
依瑪貓 2023-02-02 00:19:11 +08:00
parent d9624c7be6
commit 6876fdf75e

View File

@ -201,3 +201,44 @@ class AccountTestCase(unittest.TestCase):
response = viewer.client.post("/accounting/accounts/1111-001/delete", response = viewer.client.post("/accounting/accounts/1111-001/delete",
data={"csrf_token": viewer.csrf_token}) data={"csrf_token": viewer.csrf_token})
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
def test_editor(self) -> None:
"""Test the permission as editor.
:return: None.
"""
response: httpx.Response
response = self.client.get("/accounting/accounts")
self.assertEqual(response.status_code, 200)
response = self.client.get("/accounting/accounts/1111-001")
self.assertEqual(response.status_code, 200)
response = self.client.get("/accounting/accounts/create")
self.assertEqual(response.status_code, 200)
response = self.client.post("/accounting/accounts/store",
data={"csrf_token": self.csrf_token,
"base_code": "1113",
"title": "1113 title"})
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"],
"/accounting/accounts/1113-001")
response = self.client.get("/accounting/accounts/1111-001/edit")
self.assertEqual(response.status_code, 200)
response = self.client.post("/accounting/accounts/1111-001/update",
data={"csrf_token": self.csrf_token,
"base_code": "1111",
"title": "1111 title #2"})
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"],
"/accounting/accounts/1111-001")
response = self.client.post("/accounting/accounts/1111-001/delete",
data={"csrf_token": self.csrf_token})
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"],
"/accounting/accounts")