123456789101112131415161718192021222324252627282930313233343536 |
- def test_get_remote_config(self, mocker: MockFixture, azure_layer: Mock) -> None:
- mocked_creds = mocker.Mock()
- mocked_default_creds = mocker.patch(
- "opta.core.azure.DefaultAzureCredential", return_value=mocked_creds
- )
- mocked_container_client_instance = mocker.Mock()
- mocked_container_client_instance.download_blob = mocker.Mock()
- download_stream_mock = mocker.Mock()
- download_stream_mock.readall = mocker.Mock(
- return_value='{"opta_version":"1", "date": "mock_date", "original_spec": "mock_spec", "defaults": {}}'
- )
- mocked_container_client_instance.download_blob.return_value = download_stream_mock
- mocked_container_client = mocker.patch(
- "opta.core.azure.ContainerClient",
- return_value=mocked_container_client_instance,
- )
- mocked_structured_config: StructuredConfig = {
- "opta_version": "1",
- "date": "mock_date",
- "original_spec": "mock_spec",
- "defaults": {},
- }
- assert Azure(azure_layer).get_remote_config() == mocked_structured_config
- azure_layer.gen_providers.assert_called_once_with(0)
- mocked_default_creds.assert_called_once_with()
- mocked_container_client.assert_called_once_with(
- account_url="https://dummy_storage_account.blob.core.windows.net",
- container_name="dummy_container_name",
- credential=mocked_creds,
- )
- mocked_container_client_instance.download_blob.assert_called_once_with(
- f"opta_config/{azure_layer.name}"
- )
|