Skip to content

Commit

Permalink
Merge branch 'support-static-index' of github.com-dwreeves:dwreeves/a…
Browse files Browse the repository at this point in the history
…stronomer-cosmos into support-static-index
  • Loading branch information
dwreeves committed Jun 9, 2024
2 parents 2e3acda + 781c6eb commit 0f2ca86
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/plugin/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_dbt_docs_artifact(mock_open_file, monkeypatch, app, artifact):
@patch.object(cosmos.plugin, "open_file")
@pytest.mark.parametrize("artifact", ["dbt_docs_index.html", "manifest.json", "catalog.json"])
def test_dbt_docs_artifact_not_found(mock_open_file, monkeypatch, app, artifact):
monkeypatch.setattr("cosmos.plugin.dbt_docs_dir", "path/to/docs/dir")
mock_open_file.side_effect = FileNotFoundError

response = app.get(f"/cosmos/{artifact}")
Expand Down Expand Up @@ -162,7 +163,7 @@ def test_open_s3_file_not_found():
mock_module = MagicMock()
with patch.dict(sys.modules, {"airflow.providers.amazon.aws.hooks.s3": mock_module}):
mock_hook = mock_module.S3Hook.return_value
mock_hook.read_key.side_effect = lambda: ClientError({"Error": {"Code": "NoSuchKey"}}, "")
mock_hook.read_key.side_effect = lambda *a, **kw: ClientError({"Error": {"Code": "NoSuchKey"}}, "")

with pytest.raises(FileNotFoundError):
open_s3_file("s3://mock-path/to/docs", conn_id="mock-conn-id")
Expand Down Expand Up @@ -196,7 +197,7 @@ def test_open_gcs_file_not_found():
mock_module = MagicMock()
with patch.dict(sys.modules, {"airflow.providers.google.cloud.hooks.gcs": mock_module}):
mock_hook = mock_module.GCSHook.return_value = MagicMock()
mock_hook.download.side_effect = NotFound
mock_hook.download.side_effect = lambda *a, **kw: NotFound("")

with pytest.raises(FileNotFoundError):
open_gcs_file("gs://mock-path/to/docs", conn_id="mock-conn-id")
Expand Down Expand Up @@ -231,7 +232,7 @@ def test_open_azure_file_not_found():
mock_module = MagicMock()
with patch.dict(sys.modules, {"airflow.providers.microsoft.azure.hooks.wasb": mock_module}):
mock_hook = mock_module.GCSHook.return_value = MagicMock()
mock_hook.download.side_effect = ResourceNotFoundError
mock_hook.read_file.side_effect = lambda *a, **kw: ResourceNotFoundError()

with pytest.raises(FileNotFoundError):
open_azure_file("wasb://mock-path/to/docs", conn_id="mock-conn-id")
Expand Down

0 comments on commit 0f2ca86

Please sign in to comment.