@@ -94,6 +94,7 @@ class TestActivityItems:
9494 "message_item_create" ,
9595 "audio_player_item_create" ,
9696 "paragraph_text_item_create" ,
97+ "request_health_record_data_create" ,
9798 ),
9899 )
99100 async def test_create_applet_with_each_activity_item (
@@ -211,6 +212,38 @@ async def test_create_applet_with_performance_task(
211212 assert resp .json ()["result" ]["activities" ][0 ]["isPerformanceTask" ]
212213 assert resp .json ()["result" ]["activities" ][0 ]["performanceTaskType" ] == performance_task_type
213214
215+ async def test_create_applet_with_request_health_record_data_invalid (
216+ self ,
217+ client : TestClient ,
218+ tom : User ,
219+ applet_minimal_data : AppletCreate ,
220+ request_health_record_data_create : ActivityItemCreate ,
221+ ):
222+ client .login (tom )
223+ data = applet_minimal_data .copy (deep = True )
224+ data .activities [0 ].items = [request_health_record_data_create ]
225+
226+ data_dict = data .dict (by_alias = True )
227+ data_dict ["activities" ][0 ]["items" ][0 ]["responseValues" ]["optInOutOptions" ][1 ]["id" ] = "opt_in"
228+
229+ resp = await client .post (self .applet_create_url .format (owner_id = tom .id ), data = data_dict )
230+ assert resp .status_code == http .HTTPStatus .UNPROCESSABLE_ENTITY
231+ assert resp .json ()["result" ][0 ]["message" ] == "Request Health Record Data item must have opt-out option"
232+
233+ data_dict = data .dict (by_alias = True )
234+ data_dict ["activities" ][0 ]["items" ][0 ]["responseValues" ]["optInOutOptions" ][0 ]["id" ] = "opt_out"
235+
236+ resp = await client .post (self .applet_create_url .format (owner_id = tom .id ), data = data_dict )
237+ assert resp .status_code == http .HTTPStatus .UNPROCESSABLE_ENTITY
238+ assert resp .json ()["result" ][0 ]["message" ] == "Request Health Record Data item must have opt-in option"
239+
240+ data_dict = data .dict (by_alias = True )
241+ data_dict ["activities" ][0 ]["items" ][0 ]["responseValues" ]["optInOutOptions" ] = []
242+
243+ resp = await client .post (self .applet_create_url .format (owner_id = tom .id ), data = data_dict )
244+ assert resp .status_code == http .HTTPStatus .UNPROCESSABLE_ENTITY
245+ assert resp .json ()["result" ][0 ]["message" ] == "Request Health Record Data item must have 2 opt-in/out options"
246+
214247 async def test_creating_applet_with_activity_items_condition (
215248 self ,
216249 client : TestClient ,
0 commit comments