Skip to content

Commit

Permalink
fix: adds more answer tests to cover flow id on activityOrFlowId field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramir Mesquita committed Dec 13, 2024
1 parent 7bda73f commit 4a605a3
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/apps/answers/tests/test_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,27 @@ async def test_answer_skippable_activity_items_create_for_respondent(
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1

async def test_answer_skippable_activity_items_create_for_respondent_with_flow_id(
self, client: TestClient, tom: User, answer_create: AppletAnswerCreate, applet: AppletFull
):
client.login(tom)

response = await client.post(self.answer_url, data=answer_create)

assert response.status_code == http.HTTPStatus.CREATED, response.json()

response = await client.get(
self.applet_submit_dates_url.format(applet_id=str(applet.id)),
dict(
respondentId=tom.id,
fromDate=datetime.date.today() - datetime.timedelta(days=10),
toDate=datetime.date.today() + datetime.timedelta(days=10),
activityOrFlowId=applet.activity_flows[0].id,
),
)
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1

async def test_list_submit_dates(
self, client: TestClient, tom: User, answer_create: AppletAnswerCreate, applet: AppletFull
):
Expand All @@ -1027,6 +1048,26 @@ async def test_list_submit_dates(
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1

async def test_list_submit_dates_with_flow_id(
self, client: TestClient, tom: User, answer_create: AppletAnswerCreate, applet: AppletFull
):
client.login(tom)

response = await client.post(self.answer_url, data=answer_create)
assert response.status_code == http.HTTPStatus.CREATED

response = await client.get(
self.applet_submit_dates_url.format(applet_id=str(applet.id)),
dict(
respondentId=tom.id,
fromDate=datetime.date.today() - datetime.timedelta(days=10),
toDate=datetime.date.today() + datetime.timedelta(days=10),
activityOrFlowId=applet.activity_flows[0].id,
),
)
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1

async def test_answer_flow_items_create_for_respondent(
self, client: TestClient, tom: User, answer_create: AppletAnswerCreate
):
Expand Down
65 changes: 65 additions & 0 deletions src/apps/answers/tests/test_answers_arbitrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,71 @@ async def test_answer_skippable_activity_items_create_for_respondent(
assert len(response.json()["result"]["dates"]) == 1
await assert_answer_exist_on_arbitrary(str(answer_create.submit_id), arbitrary_session)

async def test_answer_skippable_activity_items_create_for_respondent_with_flow_id(
self,
arbitrary_session: AsyncSession,
arbitrary_client: TestClient,
tom: User,
answer_create: AppletAnswerCreate,
applet: AppletFull,
):
arbitrary_client.login(tom)

response = await arbitrary_client.post(self.answer_url, data=answer_create)

assert response.status_code == http.HTTPStatus.CREATED, response.json()

response = await arbitrary_client.get(
self.applet_submit_dates_url.format(applet_id=str(applet.id)),
dict(
respondentId=tom.id,
fromDate=datetime.date.today() - datetime.timedelta(days=10),
toDate=datetime.date.today() + datetime.timedelta(days=10),
activityOrFlowId=applet.activity_flows[0].id,
),
)
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1
await assert_answer_exist_on_arbitrary(str(answer_create.submit_id), arbitrary_session)

async def test_list_submit_dates_with_flow_id(
self,
arbitrary_session: AsyncSession,
arbitrary_client: TestClient,
tom: User,
answer_create: AppletAnswerCreate,
applet: AppletFull,
):
arbitrary_client.login(tom)

response = await arbitrary_client.post(self.answer_url, data=answer_create)
assert response.status_code == http.HTTPStatus.CREATED

response = await arbitrary_client.get(
self.applet_submit_dates_url.format(applet_id=str(applet.id)),
dict(
respondentId=tom.id,
fromDate=datetime.date.today() - datetime.timedelta(days=10),
toDate=datetime.date.today() + datetime.timedelta(days=10),
activityOrFlowId=applet.activity_flows[0].id,
),
)
assert response.status_code == http.HTTPStatus.OK
assert len(response.json()["result"]["dates"]) == 1
await assert_answer_exist_on_arbitrary(str(answer_create.submit_id), arbitrary_session)

response = await arbitrary_client.get(
self.applet_submit_dates_url.format(applet_id=str(applet.id)),
dict(
respondentId=tom.id,
fromDate=datetime.date.today() - datetime.timedelta(days=10),
toDate=datetime.date.today() + datetime.timedelta(days=10),
activityOrFlowId=applet.activity_flows[0].id,
),
)
assert response.status_code == 200
assert len(response.json()["result"]["dates"]) == 1

async def test_list_submit_dates(
self,
arbitrary_session: AsyncSession,
Expand Down

0 comments on commit 4a605a3

Please sign in to comment.