Skip to content

Commit

Permalink
Add #19 Update bdd test to support issue feature/612 revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Jan 10, 2024
1 parent 3b30c5a commit cea4d5a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 29 deletions.
22 changes: 11 additions & 11 deletions features/issue_fix_610/issue_fix_610.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ Feature: Issue fix 610
| dataAgreementId |
| 1 |
| 659c12ea3140212807b80000 |

@positive @delete_data_agreement
Scenario Outline: CONFIG - DELETE - Delete data agreement
Given a data agreement ID "<dataAgreementId>"
When I make a DELETE request to /config/data-agreement/"<dataAgreementId>"
Then The response should have a status code of 200
And The response should only contain the data agreement revision details for "<dataAgreementId>"

Examples: Valid data
| dataAgreementId |
| 659e5aafa35cad660a9021f5 |

@positive @list_data_agreement_revisions
Scenario Outline: CONFIG - LIST - List data agreement revisions
Expand Down Expand Up @@ -197,15 +208,4 @@ Feature: Issue fix 610
| dataAgreementId | consentRecordId | individualId |
| 1 | 1 | 1 |

@positive @delete_data_agreement
Scenario Outline: CONFIG - DELETE - Delete data agreement
Given a data agreement ID "<dataAgreementId>"
When I make a DELETE request to /config/data-agreement/"<dataAgreementId>"
Then The response should have a status code of 200
And The response should only contain the data agreement revision details for "<dataAgreementId>"

Examples: Valid data
| dataAgreementId |
| 659c12ea3140212807b80000 |


4 changes: 2 additions & 2 deletions fixtures/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def populate_revisions(db):
"_id": revision.get(
"id", generate_object_id(seed_year + index, 1, 1)
),
"schemaname": revision.get("schemaName", "dataAgreement"),
"schemaname": revision.get("schemaName", "DataAgreement"),
"objectid": revision.get("objectId", "1"),
"signedwithoutobjectid": revision.get(
"signedWithoutObjectId", False
Expand All @@ -420,7 +420,7 @@ def populate_revisions(db):
"authorizedbyindividualid": revision.get(
"authorizedByIndividualId", ""
),
"authorizedbyotherid": revision.get("authorizedByOtherId", ""),
"authorizedbyother": revision.get("authorizedByOther", ""),
"predecessorhash": revision.get("predecessorHash", ""),
"predecessorsignature": revision.get("predecessorSignature", ""),
"objectdata": revision.get("objectData", ""),
Expand Down
27 changes: 19 additions & 8 deletions steps/issue_fix_610.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def step_impl(context, dataAgreementId):
response_data = json.loads(context.response.content)
assert response_data["dataAgreement"]["id"] == dataAgreementId, "Data agreement ID does not match"
assert response_data["revision"]["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID"
assert response_data["revision"]["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement"
assert response_data["revision"]["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement"
assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when('I make a GET request to /config/data-agreements')
def step_impl(context):
Expand Down Expand Up @@ -64,9 +65,11 @@ def step_impl(context, dataAgreementId):
response_data = json.loads(context.response.content)
revisions = response_data["revisions"]
assert response_data["dataAgreement"]["id"] == dataAgreementId, "Data agreement ID does not match"
assert len(revisions) > 0, "Revisions is empty"
for revision in revisions:
assert revision["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID"
assert revision["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement"
assert revision["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement"
assert len(revision["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@given("a policy ID \"{policyId}\"")
def step_impl(context, policyId):
Expand All @@ -87,7 +90,8 @@ def step_impl(context, policyId):
response_data = json.loads(context.response.content)
assert response_data["policy"]["id"] == policyId, "Policy ID does not match"
assert response_data["revision"]["objectId"] == policyId, "Revision object ID does not match policy ID"
assert response_data["revision"]["schemaName"] == "policy", "Revision schema name does not match policy"
assert response_data["revision"]["schemaName"] == "Policy", "Revision schema name does not match policy"
assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when('I make a GET request to /config/policies')
def step_impl(context):
Expand Down Expand Up @@ -127,9 +131,11 @@ def step_impl(context, policyId):
response_data = json.loads(context.response.content)
revisions = response_data["revisions"]
assert response_data["policy"]["id"] == policyId, "Policy ID does not match"
assert len(revisions) > 0, "Revisions is empty"
for revision in revisions:
assert revision["objectId"] == policyId, "Revision object ID does not match policy ID"
assert revision["schemaName"] == "policy", "Revision schema name does not match policy"
assert revision["schemaName"] == "Policy", "Revision schema name does not match policy"
assert len(revision["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when("I make a DELETE request to /config/policy/\"{policyId}\"")
def step_impl(context, policyId):
Expand All @@ -144,7 +150,8 @@ def step_impl(context, policyId):
# Parse the response content and assert the data agreement details
response_data = json.loads(context.response.content)
assert response_data["objectId"] == policyId, "Revision object ID does not match policy ID"
assert response_data["schemaName"] == "policy", "Revision schema name does not match policy"
assert response_data["schemaName"] == "Policy", "Revision schema name does not match policy"
assert len(response_data["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when('I make a GET request to /service/data-agreement/\"{dataAgreementId}\"')
def step_impl(context, dataAgreementId):
Expand Down Expand Up @@ -207,7 +214,8 @@ def step_impl(context):
response_data = json.loads(context.response.content)
assert response_data["consentRecord"]["dataAgreementId"] == context.data_agreement_id, "Data agreement Id does not match for consent record"
assert response_data["consentRecord"]["individualId"] == context.individual_id, "Individual Id does not match for consent record"
assert response_data["revision"]["schemaName"] == "consentRecord", "Revision schema name does not match consentRecord"
assert response_data["revision"]["schemaName"] == "ConsentRecord", "Revision schema name does not match consentRecord"
assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when('I make a GET request to /service/individual/record/data-agreement/\"{dataAgreementId}\"')
def step_impl(context,dataAgreementId):
Expand Down Expand Up @@ -246,7 +254,8 @@ def step_impl(context, consentRecordId):
assert response_data["consentRecord"]["dataAgreementId"] == context.data_agreement_id, "Data agreement Id does not match for consent record"
assert response_data["consentRecord"]["individualId"] == context.individual_id, "Individual Id does not match for consent record"
assert response_data["revision"]["objectId"] == consentRecordId, "Revision object ID does not match consent record ID"
assert response_data["revision"]["schemaName"] == "consentRecord", "Revision schema name does not match consentRecord"
assert response_data["revision"]["schemaName"] == "ConsentRecord", "Revision schema name does not match consentRecord"
assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"

@when('I make a PUT request to /service/individual/record/consent-record/\"{consentRecordId}\"')
def step_impl(context,consentRecordId,):
Expand Down Expand Up @@ -276,6 +285,7 @@ def step_impl(context, consentRecordId):
response_data = json.loads(context.response.content)
consent_records = response_data["consentRecords"]
consent_record_id_found = False
assert len(consent_records) > 0, "Consent records is empty"
for consent_record in consent_records:
if consent_record.get("id") == consentRecordId:
consent_record_id_found = True
Expand Down Expand Up @@ -308,7 +318,8 @@ def step_impl(context, dataAgreementId):
# Parse the response content and assert the data agreement details
response_data = json.loads(context.response.content)
assert response_data["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID"
assert response_data["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement"
assert response_data["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement"
assert len(response_data["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther"



Loading

0 comments on commit cea4d5a

Please sign in to comment.