diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index eb88eb053e6..aea46bfe018 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -449,7 +449,7 @@ async def get_versions_by_activity_id(self, activity_id: uuid.UUID) -> list[Vers for _, version, created_at, flow_history_id, _ in db_result.all(): # Filters out the activities associated with flows to display only isolated activities - if flow_history_id.endswith(version): + if flow_history_id and flow_history_id.endswith(version): results.append(Version(version=version, created_at=created_at)) return results diff --git a/src/apps/answers/tests/test_answers.py b/src/apps/answers/tests/test_answers.py index da6fef550bc..215402aa4f7 100644 --- a/src/apps/answers/tests/test_answers.py +++ b/src/apps/answers/tests/test_answers.py @@ -1008,7 +1008,7 @@ async def test_answer_skippable_activity_items_create_for_respondent( 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 + self, client: TestClient, tom: User, answer_create: AppletAnswerCreate, applet_with_flow: AppletFull ): client.login(tom) @@ -1017,12 +1017,12 @@ async def test_answer_skippable_activity_items_create_for_respondent_with_flow_i assert response.status_code == http.HTTPStatus.CREATED, response.json() response = await client.get( - self.applet_submit_dates_url.format(applet_id=str(applet.id)), + self.applet_submit_dates_url.format(applet_id=str(applet_with_flow.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, + activityOrFlowId=applet_with_flow.activity_flows[0].id, ), ) assert response.status_code == http.HTTPStatus.OK @@ -1049,7 +1049,7 @@ async def test_list_submit_dates( 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 + self, client: TestClient, tom: User, answer_create: AppletAnswerCreate, applet_with_flow: AppletFull ): client.login(tom) @@ -1057,12 +1057,12 @@ async def test_list_submit_dates_with_flow_id( assert response.status_code == http.HTTPStatus.CREATED response = await client.get( - self.applet_submit_dates_url.format(applet_id=str(applet.id)), + self.applet_submit_dates_url.format(applet_id=str(applet_with_flow.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, + activityOrFlowId=applet_with_flow.activity_flows[0].id, ), ) assert response.status_code == http.HTTPStatus.OK diff --git a/src/apps/answers/tests/test_answers_arbitrary.py b/src/apps/answers/tests/test_answers_arbitrary.py index 598f46206e5..9771717725d 100644 --- a/src/apps/answers/tests/test_answers_arbitrary.py +++ b/src/apps/answers/tests/test_answers_arbitrary.py @@ -271,7 +271,7 @@ async def test_answer_skippable_activity_items_create_for_respondent_with_flow_i arbitrary_client: TestClient, tom: User, answer_create: AppletAnswerCreate, - applet: AppletFull, + applet_with_flow: AppletFull, ): arbitrary_client.login(tom) @@ -280,12 +280,12 @@ async def test_answer_skippable_activity_items_create_for_respondent_with_flow_i 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)), + self.applet_submit_dates_url.format(applet_id=str(applet_with_flow.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, + activityOrFlowId=applet_with_flow.activity_flows[0].id, ), ) assert response.status_code == http.HTTPStatus.OK @@ -298,7 +298,7 @@ async def test_list_submit_dates_with_flow_id( arbitrary_client: TestClient, tom: User, answer_create: AppletAnswerCreate, - applet: AppletFull, + applet_with_flow: AppletFull, ): arbitrary_client.login(tom) @@ -306,12 +306,12 @@ async def test_list_submit_dates_with_flow_id( assert response.status_code == http.HTTPStatus.CREATED response = await arbitrary_client.get( - self.applet_submit_dates_url.format(applet_id=str(applet.id)), + self.applet_submit_dates_url.format(applet_id=str(applet_with_flow.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, + activityOrFlowId=applet_with_flow.activity_flows[0].id, ), ) assert response.status_code == http.HTTPStatus.OK @@ -319,12 +319,12 @@ async def test_list_submit_dates_with_flow_id( 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)), + self.applet_submit_dates_url.format(applet_id=str(applet_with_flow.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, + activityOrFlowId=applet_with_flow.activity_flows[0].id, ), ) assert response.status_code == 200