--
This commit is contained in:
@@ -33,8 +33,9 @@ async def _audit_count(db, entity_id, action) -> int:
|
||||
|
||||
|
||||
class TestReports:
|
||||
async def _submitted(self, client, auth, org):
|
||||
async def _submitted(self, client, auth, org, approved_plan):
|
||||
doctors, _ = await _create_masters(client, auth, org, n_doctors=1, n_chemists=1)
|
||||
await approved_plan()
|
||||
dcr = (await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()})).json()["id"]
|
||||
await client.post(
|
||||
f"{API}/dcr/{dcr}/calls/doctor", headers=auth["mr1"],
|
||||
@@ -42,8 +43,8 @@ class TestReports:
|
||||
)
|
||||
return dcr, doctors
|
||||
|
||||
async def test_submitting_twice_is_one_submission(self, client, auth, org, db):
|
||||
dcr, _ = await self._submitted(client, auth, org)
|
||||
async def test_submitting_twice_is_one_submission(self, client, auth, org, db, approved_plan):
|
||||
dcr, _ = await self._submitted(client, auth, org, approved_plan)
|
||||
first = await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"])
|
||||
second = await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"])
|
||||
assert first.status_code == second.status_code == 200
|
||||
@@ -51,8 +52,8 @@ class TestReports:
|
||||
assert second.json()["submitted_at"] == first.json()["submitted_at"]
|
||||
assert await _audit_count(db, dcr, "SUBMIT") == 1
|
||||
|
||||
async def test_approving_twice_is_one_approval(self, client, auth, org, db):
|
||||
dcr, _ = await self._submitted(client, auth, org)
|
||||
async def test_approving_twice_is_one_approval(self, client, auth, org, db, approved_plan):
|
||||
dcr, _ = await self._submitted(client, auth, org, approved_plan)
|
||||
await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"])
|
||||
first = await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={})
|
||||
second = await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={})
|
||||
@@ -60,14 +61,14 @@ class TestReports:
|
||||
assert second.json()["approved_at"] == first.json()["approved_at"]
|
||||
assert await _audit_count(db, dcr, "APPROVE") == 1
|
||||
|
||||
async def test_an_area_manager_of_another_hq_still_cannot_approve(self, client, auth, org):
|
||||
dcr, _ = await self._submitted(client, auth, org)
|
||||
async def test_an_area_manager_of_another_hq_still_cannot_approve(self, client, auth, org, approved_plan):
|
||||
dcr, _ = await self._submitted(client, auth, org, approved_plan)
|
||||
await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"])
|
||||
await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={})
|
||||
assert (await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am2"], json={})).status_code == 403
|
||||
|
||||
async def test_adding_the_same_visit_or_creating_the_same_report_twice_is_refused(self, client, auth, org):
|
||||
dcr, doctors = await self._submitted(client, auth, org)
|
||||
async def test_adding_the_same_visit_or_creating_the_same_report_twice_is_refused(self, client, auth, org, approved_plan):
|
||||
dcr, doctors = await self._submitted(client, auth, org, approved_plan)
|
||||
again = await client.post(
|
||||
f"{API}/dcr/{dcr}/calls/doctor", headers=auth["mr1"],
|
||||
json={"doctor_id": doctors[0]["id"], "visit_time": "10:30:00", "call_outcome": "MET"},
|
||||
|
||||
Reference in New Issue
Block a user