Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dwreeves committed Jun 9, 2024
1 parent 1baa00f commit 883b67f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/plugin/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,27 @@ def test_open_http_file(conn_id):
assert res == "mock file contents"


def test_open_http_file_not_found():
from requests.exceptions import HTTPError

mock_module = MagicMock()
with patch.dict(sys.modules, {"airflow.providers.http.hooks.http": mock_module}):
mock_hook = mock_module.HttpHook.return_value = MagicMock()

def side_effect(*args, **kwargs):
raise HTTPError("404 Client Error: Not Found for url: https://google.com/this/is/a/fake/path")

mock_hook.read_file.side_effect = side_effect

with pytest.raises(FileNotFoundError):
open_http_file("https://google.com/this/is/a/fake/path", conn_id="mock-conn-id")

mock_module.HttpHook.assert_called_once()


"404 Client Error: Not Found for url: https://google.com/ashjdfasdkfahdjsf"


@patch("builtins.open", new_callable=mock_open, read_data="mock file contents")
def test_open_file_local(mock_file):
res = open_file("/my/path")
Expand Down

0 comments on commit 883b67f

Please sign in to comment.