@@ -94,17 +94,16 @@ def create_post_document_reference_step(context: Context, ods_code: str):
9494 context .add_cleanup (lambda : context .repository .delete_by_id (doc_ref_id ))
9595
9696
97- @when (
98- "producer 'TSTCUS' requests creation of a DocumentReference with default test values except '{section}' is"
99- )
100- def create_post_body_step (context : Context , section : str ):
97+ def _create_or_upsert_body_step (
98+ context : Context , method : str , pointer_id : str = "TSTCUS-sample-id-00000"
99+ ):
101100 client = producer_client_from_context (context , "TSTCUS" )
102101
103102 if not context .text :
104103 raise ValueError ("No document reference text snippet provided" )
105104
106- doc_ref = create_test_document_reference_with_defaults (section , context .text )
107- context .response = client . create_text (doc_ref )
105+ doc_ref = create_test_document_reference_with_defaults ("content" , context .text )
106+ context .response = getattr ( client , method ) (doc_ref )
108107
109108 if context .response .status_code == 201 :
110109 doc_ref_id = context .response .headers ["Location" ].split ("/" )[- 1 ]
@@ -114,6 +113,20 @@ def create_post_body_step(context: Context, section: str):
114113 context .add_cleanup (lambda : context .repository .delete_by_id (doc_ref_id ))
115114
116115
116+ @when (
117+ "producer 'TSTCUS' requests creation of a DocumentReference with default test values except '{section}' is"
118+ )
119+ def create_post_body_step (context : Context , section : str ):
120+ _create_or_upsert_body_step (context , "create_text" )
121+
122+
123+ @when (
124+ "producer 'TSTCUS' requests upsert of a DocumentReference with pointerId '{pointer_id}' and default test values except '{section}' is"
125+ )
126+ def upsert_post_body_step (context : Context , section : str , pointer_id : str ):
127+ _create_or_upsert_body_step (context , "upsert_text" , pointer_id )
128+
129+
117130@when ("producer '{ods_code}' upserts a DocumentReference with values" )
118131def create_put_document_reference_step (context : Context , ods_code : str ):
119132 client = producer_client_from_context (context , ods_code )
0 commit comments