Skip to content

Commit e91e34c

Browse files
NRL-518 Add method to change default parameters for an update
1 parent 8c7e27c commit e91e34c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/features/steps/2_request.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
from behave import * # noqa
24
from behave.runner import Context
35

@@ -130,6 +132,28 @@ def upsert_post_body_step(context: Context, section: str, pointer_id: str):
130132
_create_or_upsert_body_step(context, "upsert_text", section, pointer_id)
131133

132134

135+
@when(
136+
"producer 'TSTCUS' requests update of a DocumentReference with pointerId '{pointer_id}' and only changing"
137+
)
138+
def update_post_body_step(context: Context, pointer_id: str):
139+
"""
140+
Updates an existing DocumentReference with new values for a specific section
141+
"""
142+
consumer_client = consumer_client_from_context(context, "TSTCUS")
143+
context.response = consumer_client.read(pointer_id)
144+
145+
if context.response.status_code != 200:
146+
raise ValueError(f"Failed to read existing pointer: {context.response.text}")
147+
148+
doc_ref = context.response.json()
149+
custom_data = json.loads(context.text)
150+
for key in custom_data:
151+
doc_ref[key] = custom_data[key]
152+
153+
producer_client = producer_client_from_context(context, "TSTCUS")
154+
context.response = producer_client.update(doc_ref, pointer_id)
155+
156+
133157
@when("producer '{ods_code}' upserts a DocumentReference with values")
134158
def create_put_document_reference_step(context: Context, ods_code: str):
135159
client = producer_client_from_context(context, ods_code)

0 commit comments

Comments
 (0)