Skip to content

Commit

Permalink
Add #23 Add bdd test for issue_614.feature
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Jan 11, 2024
1 parent 610c95e commit 4d09907
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gherkin/features/issue_614/issue_614.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: Update consent record

@positive
Scenario Outline: Update consent record with new request body and without query params
When I update consent record with id "<consentRecordId>", request body `{"consentRecord":{"optIn":true}}` and without query params
When I update consent record with id "<consentRecordId>", request body `{new request body}` and without query params
Then It returns a consent record and revision. Check if consent record contains optIn as true

Examples:
Expand Down
54 changes: 54 additions & 0 deletions gherkin/steps/issue_614.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import json

import requests
from behave import *


@when(
'I update consent record with id "{consentRecordId}", request body `{"optIn":false}` and without query params'
)
def step_impl(context, consentRecordId):
base_url = context.config.userdata.get("base_url")
data = {"optIn": False}
# Construct the full API endpoint URL
url = base_url + f"/service/individual/record/consent-record/{consentRecordId}"
# Make the PUT request
response = requests.put(url + "/", verify=False, json=data)
context.response = response


@then(
"It returns a consent record and revision. Check if consent record contains optIn as false"
)
def step_impl(context):
response_data = json.loads(context.response.content)
assert "consentRecord" in response_data, "Response does not contains consent record"
assert "revision" in response_data, "Response does not contains revision"
assert (
response_data["consentRecord"]["optIn"] == False
), "Consent record does not contain optIn as false"


@when(
'I update consent record with id "{consentRecordId}", request body `{new request body}` and without query params'
)
def step_impl(context, consentRecordId):
base_url = context.config.userdata.get("base_url")
data = {"consentRecord": {"optIn": True}}
# Construct the full API endpoint URL
url = base_url + f"/service/individual/record/consent-record/{consentRecordId}"
# Make the PUT request
response = requests.put(url + "/", verify=False, json=data)
context.response = response


@then(
"It returns a consent record and revision. Check if consent record contains optIn as true"
)
def step_impl(context):
response_data = json.loads(context.response.content)
assert "consentRecord" in response_data, "Response does not contains consent record"
assert "revision" in response_data, "Response does not contains revision"
assert (
response_data["consentRecord"]["optIn"] == True
), "Consent record does not contain optIn as true"

0 comments on commit 4d09907

Please sign in to comment.