From 3b7a2cb36f884a9f605bcb381674ebe37c8f64de Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Mon, 9 Dec 2024 21:08:32 -0300 Subject: [PATCH 01/13] filter: add activity_id filter to answers query and update filter schema to fix dataviz calendar issue --- src/apps/answers/crud/answers.py | 2 ++ src/apps/answers/filters.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index fb5ef8c3a9c..d435bf4eab8 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -234,6 +234,8 @@ async def get_respondents_submit_dates( query = query.where(func.date(AnswerSchema.created_at) >= filters.from_date) query = query.where(func.date(AnswerSchema.created_at) <= filters.to_date) query = query.where(AnswerSchema.applet_id == applet_id) + query = query.where(AnswerSchema.activity_history_id.contains(filters.activity_id)) + if filters.respondent_id: query = query.where(AnswerSchema.respondent_id == filters.respondent_id) if filters.target_subject_id: diff --git a/src/apps/answers/filters.py b/src/apps/answers/filters.py index ef8cf4d32c4..aa8b9a18c2a 100644 --- a/src/apps/answers/filters.py +++ b/src/apps/answers/filters.py @@ -34,6 +34,7 @@ class AppletSubmissionsFilter(BaseQueryParams): class AppletSubmitDateFilter(BaseQueryParams): respondent_id: uuid.UUID | None target_subject_id: uuid.UUID | None + activity_id: str | None from_date: datetime.date to_date: datetime.date From 400a0c6b1a016ab9f5e2da07e608e0675195bed1 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Tue, 10 Dec 2024 07:38:30 -0300 Subject: [PATCH 02/13] fix: change schema query to make more appropriate --- src/apps/answers/crud/answers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index d435bf4eab8..4be9db5f885 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -234,7 +234,7 @@ async def get_respondents_submit_dates( query = query.where(func.date(AnswerSchema.created_at) >= filters.from_date) query = query.where(func.date(AnswerSchema.created_at) <= filters.to_date) query = query.where(AnswerSchema.applet_id == applet_id) - query = query.where(AnswerSchema.activity_history_id.contains(filters.activity_id)) + query = query.where(AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_id)) if filters.respondent_id: query = query.where(AnswerSchema.respondent_id == filters.respondent_id) From 41debc80af48010bfcb23e54d2e7c59de4ea5acc Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Tue, 10 Dec 2024 17:55:46 -0300 Subject: [PATCH 03/13] fix: update activity_id filter to support activity or flowid --- src/apps/answers/crud/answers.py | 7 ++++++- src/apps/answers/filters.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index 4be9db5f885..0adf12ab632 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -234,7 +234,12 @@ async def get_respondents_submit_dates( query = query.where(func.date(AnswerSchema.created_at) >= filters.from_date) query = query.where(func.date(AnswerSchema.created_at) <= filters.to_date) query = query.where(AnswerSchema.applet_id == applet_id) - query = query.where(AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_id)) + query = query.where( + or_( + AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_or_flow_id), + AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), + ), + ) if filters.respondent_id: query = query.where(AnswerSchema.respondent_id == filters.respondent_id) diff --git a/src/apps/answers/filters.py b/src/apps/answers/filters.py index aa8b9a18c2a..59ef1eb1fc4 100644 --- a/src/apps/answers/filters.py +++ b/src/apps/answers/filters.py @@ -34,7 +34,7 @@ class AppletSubmissionsFilter(BaseQueryParams): class AppletSubmitDateFilter(BaseQueryParams): respondent_id: uuid.UUID | None target_subject_id: uuid.UUID | None - activity_id: str | None + activity_or_flow_id: uuid.UUID | None from_date: datetime.date to_date: datetime.date From cd6af87e4a2605bbd0b116abe64e69aaf6c7853c Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Tue, 10 Dec 2024 20:38:37 -0300 Subject: [PATCH 04/13] fix: improving logic for querying flux or activity id --- src/apps/answers/crud/answers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index 0adf12ab632..3dd8e32f074 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -235,10 +235,13 @@ async def get_respondents_submit_dates( query = query.where(func.date(AnswerSchema.created_at) <= filters.to_date) query = query.where(AnswerSchema.applet_id == applet_id) query = query.where( - or_( - AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_or_flow_id), - AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), - ), + case( + ( + AnswerSchema.flow_history_id.isnot(None), + AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), + ), + else_=AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_or_flow_id), + ) ) if filters.respondent_id: From 6e3483bec5eae49e0a4d19e2819b1a3d0f8fd730 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Wed, 11 Dec 2024 09:36:27 -0300 Subject: [PATCH 05/13] fix: ignoring ruff error 501 in lines --- src/apps/answers/crud/answers.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index 3dd8e32f074..848f9f4814e 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -235,13 +235,14 @@ async def get_respondents_submit_dates( query = query.where(func.date(AnswerSchema.created_at) <= filters.to_date) query = query.where(AnswerSchema.applet_id == applet_id) query = query.where( - case( - ( - AnswerSchema.flow_history_id.isnot(None), - AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), - ), - else_=AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) == str(filters.activity_or_flow_id), - ) + case( + ( + AnswerSchema.flow_history_id.isnot(None), + AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), + ), + else_=AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) + == str(filters.activity_or_flow_id), + ) ) if filters.respondent_id: From 588d2a7fc706b450cebcfc591606a26952a4d3b1 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Wed, 11 Dec 2024 09:39:26 -0300 Subject: [PATCH 06/13] fix: adds ruff ignore rules for long lines --- src/apps/answers/crud/answers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index 848f9f4814e..7df9d4b60f5 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -238,9 +238,9 @@ async def get_respondents_submit_dates( case( ( AnswerSchema.flow_history_id.isnot(None), - AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), + AnswerSchema.id_from_history_id(AnswerSchema.flow_history_id) == str(filters.activity_or_flow_id), # noqa: E501 ), - else_=AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) + else_=AnswerSchema.id_from_history_id(AnswerSchema.activity_history_id) # noqa: E501 == str(filters.activity_or_flow_id), ) ) From d1ca4d3b1d1f688318709904480e9d5fa15d1596 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Wed, 11 Dec 2024 09:56:52 -0300 Subject: [PATCH 07/13] fix: changing activity_or_flow_id to str to fix the query --- src/apps/answers/filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/answers/filters.py b/src/apps/answers/filters.py index 59ef1eb1fc4..cfaa7198029 100644 --- a/src/apps/answers/filters.py +++ b/src/apps/answers/filters.py @@ -34,7 +34,7 @@ class AppletSubmissionsFilter(BaseQueryParams): class AppletSubmitDateFilter(BaseQueryParams): respondent_id: uuid.UUID | None target_subject_id: uuid.UUID | None - activity_or_flow_id: uuid.UUID | None + activity_or_flow_id: str | None from_date: datetime.date to_date: datetime.date From e57a58facbf59a4ef0aeb920e44b96a9f2045117 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Thu, 12 Dec 2024 08:00:45 -0300 Subject: [PATCH 08/13] fix: adding missing param to the test --- src/apps/answers/tests/test_answers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/answers/tests/test_answers.py b/src/apps/answers/tests/test_answers.py index 58ce8b0c571..68fedf841a7 100644 --- a/src/apps/answers/tests/test_answers.py +++ b/src/apps/answers/tests/test_answers.py @@ -1001,6 +1001,7 @@ async def test_answer_skippable_activity_items_create_for_respondent( respondentId=tom.id, fromDate=datetime.date.today() - datetime.timedelta(days=10), toDate=datetime.date.today() + datetime.timedelta(days=10), + activityOrFlowId=applet.activities[0].id, ), ) assert response.status_code == http.HTTPStatus.OK From 8a205f97c41fcfced67883c5c9802726846b1dc4 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Thu, 12 Dec 2024 08:36:19 -0300 Subject: [PATCH 09/13] fix: adding missing answer or flow id arg to test --- src/apps/answers/tests/test_answers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/answers/tests/test_answers.py b/src/apps/answers/tests/test_answers.py index 68fedf841a7..a4c14dca809 100644 --- a/src/apps/answers/tests/test_answers.py +++ b/src/apps/answers/tests/test_answers.py @@ -1021,6 +1021,7 @@ async def test_list_submit_dates( respondentId=tom.id, fromDate=datetime.date.today() - datetime.timedelta(days=10), toDate=datetime.date.today() + datetime.timedelta(days=10), + activityOrFlowId=applet.activities[0].id, ), ) assert response.status_code == http.HTTPStatus.OK From 7bda73f6cbcabf8c981ab78f07afd2e91c25f4ed Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Thu, 12 Dec 2024 08:43:59 -0300 Subject: [PATCH 10/13] fix: adding missing answer or flow id arg to test to arbitrary test --- src/apps/answers/tests/test_answers_arbitrary.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apps/answers/tests/test_answers_arbitrary.py b/src/apps/answers/tests/test_answers_arbitrary.py index 623aa6b4e7e..4f996c8a290 100644 --- a/src/apps/answers/tests/test_answers_arbitrary.py +++ b/src/apps/answers/tests/test_answers_arbitrary.py @@ -258,6 +258,7 @@ async def test_answer_skippable_activity_items_create_for_respondent( respondentId=tom.id, fromDate=datetime.date.today() - datetime.timedelta(days=10), toDate=datetime.date.today() + datetime.timedelta(days=10), + activityOrFlowId=applet.activities[0].id, ), ) assert response.status_code == http.HTTPStatus.OK @@ -283,6 +284,7 @@ async def test_list_submit_dates( respondentId=tom.id, fromDate=datetime.date.today() - datetime.timedelta(days=10), toDate=datetime.date.today() + datetime.timedelta(days=10), + activityOrFlowId=applet.activities[0].id, ), ) assert response.status_code == http.HTTPStatus.OK @@ -295,6 +297,7 @@ async def test_list_submit_dates( respondentId=tom.id, fromDate=datetime.date.today() - datetime.timedelta(days=10), toDate=datetime.date.today() + datetime.timedelta(days=10), + activityOrFlowId=applet.activities[0].id, ), ) assert response.status_code == 200 From 4a605a36b728f1190c7a64f53366020ac1ecbd03 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Fri, 13 Dec 2024 07:22:37 -0300 Subject: [PATCH 11/13] fix: adds more answer tests to cover flow id on activityOrFlowId field --- src/apps/answers/tests/test_answers.py | 41 ++++++++++++ .../answers/tests/test_answers_arbitrary.py | 65 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/src/apps/answers/tests/test_answers.py b/src/apps/answers/tests/test_answers.py index a4c14dca809..da6fef550bc 100644 --- a/src/apps/answers/tests/test_answers.py +++ b/src/apps/answers/tests/test_answers.py @@ -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 ): @@ -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 ): diff --git a/src/apps/answers/tests/test_answers_arbitrary.py b/src/apps/answers/tests/test_answers_arbitrary.py index 4f996c8a290..598f46206e5 100644 --- a/src/apps/answers/tests/test_answers_arbitrary.py +++ b/src/apps/answers/tests/test_answers_arbitrary.py @@ -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, From c9e5a35b6760254bd09c8c5a84b6e3c4b0cc593d Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Thu, 26 Dec 2024 10:35:25 -0300 Subject: [PATCH 12/13] fix: enhance query logic to filter answers by flow history id to fix bug on summary and answers page --- src/apps/answers/crud/answers.py | 15 ++++++++++++--- src/apps/answers/filters.py | 1 + src/apps/answers/service.py | 6 ++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/apps/answers/crud/answers.py b/src/apps/answers/crud/answers.py index 7df9d4b60f5..eb88eb053e6 100644 --- a/src/apps/answers/crud/answers.py +++ b/src/apps/answers/crud/answers.py @@ -431,17 +431,26 @@ async def get_versions_by_activity_id(self, activity_id: uuid.UUID) -> list[Vers ActivityHistorySchema.id, AppletHistorySchema.version, AppletHistorySchema.created_at, + AnswerSchema.activity_history_id, + AnswerSchema.flow_history_id, ) query = query.join( AppletHistorySchema, AppletHistorySchema.id_version == ActivityHistorySchema.applet_id, ) - query = query.where(ActivityHistorySchema.id == activity_id) + query = query.outerjoin(AnswerSchema, AnswerSchema.activity_history_id.ilike(f"{str(activity_id)}%")) + query = query.where( + ActivityHistorySchema.id == activity_id, + AnswerSchema.flow_history_id.is_(None), + ) query = query.order_by(AppletHistorySchema.created_at.asc()) db_result = await self._execute(query) results = [] - for _, version, created_at in db_result.all(): - results.append(Version(version=version, created_at=created_at)) + + 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): + results.append(Version(version=version, created_at=created_at)) return results diff --git a/src/apps/answers/filters.py b/src/apps/answers/filters.py index cfaa7198029..0d5fa0d42d0 100644 --- a/src/apps/answers/filters.py +++ b/src/apps/answers/filters.py @@ -17,6 +17,7 @@ class SummaryActivityFilter(BaseQueryParams): class ReviewAppletItemFilter(BaseQueryParams): target_subject_id: uuid.UUID created_date: datetime.date + flow_id: uuid.UUID | None class AppletSubmissionsFilter(BaseQueryParams): diff --git a/src/apps/answers/service.py b/src/apps/answers/service.py index 06002d9a7fe..1aa43c4e458 100644 --- a/src/apps/answers/service.py +++ b/src/apps/answers/service.py @@ -504,6 +504,12 @@ async def get_review_activities( old_activity_answer_dates: dict[uuid.UUID, list[AnswerDate]] = defaultdict(list) activity_history_ids = set() for answer in answers: + if filters.flow_id: + if not answer.flow_history_id or not answer.flow_history_id.startswith(str(filters.flow_id)): + continue + elif answer.flow_history_id: + continue + activity_id, _ = HistoryAware.split_id_version(answer.activity_history_id) if _activity := activity_map.get(activity_id): _activity.answer_dates.append( From 58a3baabe1ac93ebdf14a4a1e75bc0914627ae03 Mon Sep 17 00:00:00 2001 From: Ramir Mesquita Date: Fri, 27 Dec 2024 08:37:09 -0300 Subject: [PATCH 13/13] fix: ensure flow_history_id is checked before filtering versions in answers --- src/apps/answers/crud/answers.py | 2 +- src/apps/answers/tests/test_answers.py | 12 ++++++------ src/apps/answers/tests/test_answers_arbitrary.py | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) 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