Commit 1c5b224d authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Trying to fix unit tests

parent 38c18cd4
......@@ -27,7 +27,7 @@ class TestDefaultConfigManager:
@pytest.fixture
def default_config_file(self):
cwd = os.getcwd()
config_file = f"{os.path.dirname(__file__)}/fake_config/osdu_api.ini"
config_file = f"{os.path.dirname(__file__)}/fake_configosdu_api.ini"
path = shutil.copy(config_file, cwd)
yield path
os.remove(path)
......@@ -37,12 +37,12 @@ class TestDefaultConfigManager:
DefaultConfigManager()
def test_configmanager_with_env_var(self):
config_file = f"{os.path.dirname(__file__)}/fake_config/osdu_api.ini"
config_file = f"{os.path.dirname(__file__)}/fake_configosdu_api.ini"
os.environ["OSDU_API_CONFIG_INI"] = config_file
DefaultConfigManager()
def test_configmanager_with_passed_directly(self):
config_file = f"{os.path.dirname(__file__)}/fake_config/osdu_api.ini"
config_file = f"{os.path.dirname(__file__)}/fake_configosdu_api.ini"
DefaultConfigManager(config_file)
def test_raise_error_if_no_file(self):
......
......@@ -13,23 +13,23 @@
# limitations under the License.
[environment]
data_partition_id=opendes
storage_url=%(STORAGE_BASE_URL)s/api/storage/v2
search_url=%(SEARCH_BASE_URL)s/api/search/v2
legal_url=%(LEGAL_BASE_URL)s/api/legal/v1
data_workflow_url=%(DATA_WORKFLOW_BASE_URL)s/api/data-workflow/v1
entitlements_url=%(ENTITLEMENTS_BASE_URL)s/api/entitlements/v1
file_dms_url=%(FILE_DMS_BASE_URL)s/api/filedms/v2
dataset_url=%(DATASET_REGISTRY_BASE_URL)s/api/dataset-registry/v1
schema_url=%(SCHEMA_BASE_URL)s/api/schema-service/v1
storage_url=blah/api/storage/v2
search_url=blah/api/search/v2
legal_url=blah/api/legal/v1
data_workflow_url=blah/api/data-workflow/v1
entitlements_url=blah/api/entitlements/v1
file_dms_url=blah/api/filedms/v2
dataset_url=blah/api/dataset-registry/v1
schema_url=blah/api/schema-service/v1
ingestion_workflow_url=stub
use_service_principal=True
[provider]
name=aws
service_principal_module_name=service_principal_util
token_url=%(AUTH_TOKEN_URL)s
aws_oauth_custom_scope=%(CUSTOM_SCOPE)s
client_id_ssm_path=/osdu/%(ENVIRONMENT)s/client-credentials-client-id
client_secret_name=/osdu/%(ENVIRONMENT)s/client_credenials_secret
token_url_ssm_path=/osdu/blah/oauth-token-uri
aws_oauth_custom_scope_ssm_path=/osdu/blah/oauth-custom-scope
client_id_ssm_path=/osdu/blah/client-credentials-client-id
client_secret_name=/osdu/blah/client_credentials_secret
client_secret_dict_key=client_credentials_client_secret
region_name=%(AWS_REGION)s
\ No newline at end of file
region_name=blah
\ No newline at end of file
......@@ -19,7 +19,7 @@ import responses
from osdu_api.clients.base_client import BaseClient
from osdu_api.model.http_method import HttpMethod
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestBaseClient(unittest.TestCase):
......@@ -28,7 +28,7 @@ class TestBaseClient(unittest.TestCase):
# Arrange
# Act
client = BaseClient("opendes")
client = BaseClient(DefaultConfigManager('osdu_api.ini'), "opendes")
# Assert
mocked_token_method.assert_called()
......@@ -37,7 +37,7 @@ class TestBaseClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, mocked_token_method):
# Arrange
client = BaseClient("opendes")
client = BaseClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
responses.add(responses.PUT, 'http://stubbed', json={'response': 'true'}, status=200)
......
......@@ -19,6 +19,7 @@ from osdu_api.clients.base_client import BaseClient
from osdu_api.clients.data_workflow.data_workflow_client import DataWorkflowClient
from osdu_api.model.data_workflow.start_workflow import StartWorkflow
from osdu_api.model.http_method import HttpMethod
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestDataWorkflowClient(unittest.TestCase):
......@@ -27,7 +28,7 @@ class TestDataWorkflowClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = DataWorkflowClient("opendes")
client = DataWorkflowClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
client.data_workflow_url = 'stubbed url'
client.headers = {}
......
......@@ -23,6 +23,7 @@ from osdu_api.model.storage.acl import Acl
from osdu_api.model.storage.legal import Legal
from osdu_api.model.storage.record import Record
from osdu_api.model.storage.record_ancestry import RecordAncestry
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestDatasetRegistryClient(unittest.TestCase):
......@@ -31,7 +32,7 @@ class TestDatasetRegistryClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = DatasetRegistryClient("opendes")
client = DatasetRegistryClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
client.dataset_registry_url = 'stubbed url'
client.headers = {}
......
......@@ -18,6 +18,7 @@ import mock
from osdu_api.clients.base_client import BaseClient
from osdu_api.clients.entitlements.entitlements_client import EntitlementsClient
from osdu_api.model.entitlements.group import Group
from osdu_api.configuration.config_manager import DefaultConfigManager
class Test_Entitlments_Client(unittest.TestCase):
......@@ -26,7 +27,7 @@ class Test_Entitlments_Client(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_file_upload(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = EntitlementsClient("opendes")
client = EntitlementsClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
client.entitlements_url = 'stubbed url'
client.headers = {}
......
......@@ -17,6 +17,7 @@ from osdu_api.clients.ingestion_workflow.ingestion_workflow_client import Ingest
from osdu_api.clients.base_client import BaseClient
from osdu_api.model.http_method import HttpMethod
from osdu_api.model.ingestion_workflow.create_workflow_request import CreateWorkflowRequest
from osdu_api.configuration.config_manager import DefaultConfigManager
......@@ -26,7 +27,7 @@ class TestIngestionWorkflowClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = IngestionWorkflowClient()
client = IngestionWorkflowClient(DefaultConfigManager('osdu_api.ini'), data_partition_id="osdu")
client.service_principal_token = 'stubbed'
client.ingestion_workflow_url = 'stubbed url'
client.headers = {}
......
......@@ -17,6 +17,7 @@ import mock
from osdu_api.clients.base_client import BaseClient
from osdu_api.clients.legal.legal_client import LegalClient
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestLegalClient(unittest.TestCase):
......@@ -25,7 +26,7 @@ class TestLegalClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_file_upload(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = LegalClient("opendes")
client = LegalClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
client.legal_url = 'stubbed url'
client.headers = {}
......
......@@ -25,6 +25,7 @@ from osdu_api.model.storage.acl import Acl
from osdu_api.model.storage.legal import Legal
from osdu_api.model.storage.record import Record
from osdu_api.model.storage.record_ancestry import RecordAncestry
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestRecordClient(unittest.TestCase):
......@@ -98,7 +99,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_create_update_records_model_record(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient("opendes")
record_client = RecordClient(DefaultConfigManager('osdu_api.ini'), "opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -113,7 +114,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_latest_record_version(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient("opendes")
record_client = RecordClient(DefaultConfigManager('osdu_api.ini'), "opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -130,7 +131,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_specific_record_version(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient("opendes")
record_client = RecordClient(DefaultConfigManager('osdu_api.ini'), "opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -148,7 +149,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_record_versions(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient("opendes")
record_client = RecordClient(DefaultConfigManager('osdu_api.ini'), "opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......
......@@ -19,6 +19,7 @@ from osdu_api.clients.base_client import BaseClient
from osdu_api.clients.search.search_client import SearchClient
from osdu_api.model.http_method import HttpMethod
from osdu_api.model.search.query_request import QueryRequest
from osdu_api.configuration.config_manager import DefaultConfigManager
class TestSeachClient(unittest.TestCase):
......@@ -27,7 +28,7 @@ class TestSeachClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = SearchClient("opendes")
client = SearchClient(DefaultConfigManager('osdu_api.ini'), "opendes")
client.service_principal_token = 'stubbed'
client.data_workflow_url = 'stubbed url'
client.headers = {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment