test_azure_key_vault_2.py 782 B

12345678910111213141516
  1. def test_get_conn_uri(self, mock_secret_client, mock_azure_cred):
  2. mock_cred = mock.Mock()
  3. mock_sec_client = mock.Mock()
  4. mock_azure_cred.return_value = mock_cred
  5. mock_secret_client.return_value = mock_sec_client
  6. mock_sec_client.get_secret.return_value = mock.Mock(
  7. value='postgresql://airflow:airflow@host:5432/airflow'
  8. )
  9. backend = AzureKeyVaultBackend(vault_url="https://example-akv-resource-name.vault.azure.net/")
  10. returned_uri = backend.get_conn_uri(conn_id='hi')
  11. mock_secret_client.assert_called_once_with(
  12. credential=mock_cred, vault_url='https://example-akv-resource-name.vault.azure.net/'
  13. )
  14. assert returned_uri == 'postgresql://airflow:airflow@host:5432/airflow'