"""Integration tests.""" from tests.integration.api import conftest def test_all_features(): """Returns all features with no user context.""" feature_api_client = conftest.ows_features_api_client(conftest.basic_headers()) response = feature_api_client.get_features() assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['test_feature_no_context'] == 'control' assert json_response['test_feature_vendor_context'] == 'control' assert json_response['test_feature_identity_context'] == 'control' assert json_response['test_feature_profile_context'] == 'control' def test_all_features_with_grass_vendor_context(): """Returns all features with grass vendor context.""" headers = { 'Orchard-User-Id': 'alw:999', 'Grass-Account-Type': 'vendor', 'Grass-Account-Id': '55555', 'Orchard-Identity-Id': '5d0a59de8a9f8c0d78129af1', } feature_api_client = conftest.ows_features_api_client(headers) response = feature_api_client.get_features() assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['test_feature_no_context'] == 'control' assert json_response['test_feature_vendor_context'] == 'enabled' assert json_response['test_feature_identity_context'] == 'control' assert json_response['test_feature_profile_context'] == 'control' def test_all_features_with_identity_context(): """Returns all features with itentity context.""" headers = {'Orchard-Identity-Id': '5d0a59de8a9f8c0d78129af0'} feature_api_client = conftest.ows_features_api_client(headers) response = feature_api_client.get_features() assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['test_feature_no_context'] == 'control' assert json_response['test_feature_vendor_context'] == 'control' assert json_response['test_feature_identity_context'] == 'enabled' assert json_response['test_feature_profile_context'] == 'control' def test_all_features_with_profile_context(): """Returns all features with profile context.""" headers = { 'Orchard-Profile-Id': '777', 'Orchard-Profile-Type': 'ArtistProfile', 'Orchard-Identity-Id': '5d0a59de8a9f8c0d78129af1', } feature_api_client = conftest.ows_features_api_client(headers) response = feature_api_client.get_features() assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['test_feature_no_context'] == 'control' assert json_response['test_feature_vendor_context'] == 'control' assert json_response['test_feature_identity_context'] == 'control' assert json_response['test_feature_profile_context'] == 'enabled' def test_features_vendor_user(): """When called with splitioEnabled then ows_features_example should be enabled""" feature_api_client = conftest.ows_features_api_client(conftest.basic_headers()) response = feature_api_client.get_features_vendor_user(789) assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['ows_features_example'] == 'enabled' def test_features_vendor_user_ows_features_example_default(): """When called with splitioEnabled then ows_features_example should be enabled by default""" feature_api_client = conftest.ows_features_api_client(conftest.basic_headers()) response = feature_api_client.get_features_vendor('/100/user_type/alw/user_id/789') assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['ows_features_example'] == 'enabled' def test_features_user_ows_features_example_default(): """When called with splitioEnabled then ows_features_example should be enabled by default""" feature_api_client = conftest.ows_features_api_client(conftest.basic_headers()) response = feature_api_client.get_features_user(789) assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['ows_features_example'] == 'enabled' def test_features_user_user_id_ows_features_example_default(): """When called with splitioEnabled then ows_features_example should be enabled by default""" feature_api_client = conftest.ows_features_api_client(conftest.basic_headers()) response = feature_api_client.get_features_user_type('789') assert response.status_code == 200, ( f'Reason: {response.reason} \n URL: {response.url}' ) json_response = response.json() assert json_response['ows_features_example'] == 'enabled'