added check for terms of use
parent
cf669ce624
commit
2f459597c5
|
@ -3,4 +3,11 @@ Feature: Get the active Profile Policy agreement
|
|||
|
||||
Scenario: Multiple versions of an agreement exist
|
||||
When API request for Privacy Policy is made
|
||||
Then version 999 of Privacy Policy is returned
|
||||
Then the request will be successful
|
||||
And Privacy Policy version 999 is returned
|
||||
|
||||
|
||||
Scenario: Retrieve Terms of Use
|
||||
When API request for Terms of Use is made
|
||||
Then the request will be successful
|
||||
And Terms of Use version 999 is returned
|
||||
|
|
|
@ -1,20 +1,33 @@
|
|||
from dataclasses import asdict
|
||||
from http import HTTPStatus
|
||||
import json
|
||||
|
||||
from behave import then, when
|
||||
from hamcrest import assert_that, equal_to
|
||||
|
||||
|
||||
@when('API request for Privacy Policy is made')
|
||||
def call_agreement_endpoint(context):
|
||||
context.response = context.client.get('/api/agreement/privacy-policy')
|
||||
from selene.data.account import PRIVACY_POLICY, TERMS_OF_USE
|
||||
|
||||
|
||||
@then('version {version} of Privacy Policy is returned')
|
||||
def validate_response(context, version):
|
||||
assert_that(context.response.status_code, equal_to(HTTPStatus.OK))
|
||||
@when('API request for {agreement} is made')
|
||||
def call_agreement_endpoint(context, agreement):
|
||||
if agreement == PRIVACY_POLICY:
|
||||
url = '/api/agreement/privacy-policy'
|
||||
elif agreement == TERMS_OF_USE:
|
||||
url = '/api/agreement/terms-of-use'
|
||||
else:
|
||||
raise ValueError('invalid agreement type')
|
||||
|
||||
context.response = context.client.get(url)
|
||||
|
||||
|
||||
@then('{agreement} version {version} is returned')
|
||||
def validate_response(context, agreement, version):
|
||||
response_data = json.loads(context.response.data)
|
||||
expected_response = asdict(context.privacy_policy)
|
||||
if agreement == PRIVACY_POLICY:
|
||||
expected_response = asdict(context.privacy_policy)
|
||||
elif agreement == TERMS_OF_USE:
|
||||
expected_response = asdict(context.terms_of_use)
|
||||
else:
|
||||
raise ValueError('invalid agreement type')
|
||||
|
||||
del(expected_response['effective_date'])
|
||||
assert_that(response_data, equal_to(expected_response))
|
||||
|
|
Loading…
Reference in New Issue