Skip to content

Commit

Permalink
fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
dannymeijer committed Dec 2, 2024
1 parent 7660183 commit c031ae8
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions tests/steps/test_download_file.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
from pathlib import Path
from unittest.mock import MagicMock, patch

import pytest
from requests_mock.mocker import Mocker

from koheesio import LoggingFactory
from koheesio.steps.download_file import DownloadFileStep

URL = "http://example.com/testfile.txt"
log = LoggingFactory.get_logger(name="test_download_file", inherit_from_koheesio=True)


@pytest.fixture
Expand Down Expand Up @@ -90,32 +90,18 @@ def test_download_file_step_ignore_mode(self, download_path, downloaded_file, ca
# Arrange
downloaded_file.write_bytes(b"foo")

# Act and Assert -- dry run
with caplog.at_level(logging.INFO):
with caplog.at_level("INFO"), Mocker() as mocker:
mocker.get(URL, content=b"bar")

# Act
step = DownloadFileStep(url=URL, download_path=download_path, mode="ignore")
step.log.setLevel("INFO")
step.execute()
assert "Ignoring testfile.txt based on IGNORE mode." in caplog.text

# with caplog.at_level("INFO"), Mocker() as mocker:
# mocker.get(URL, content=b"bar")
#
# # FIXME: logging is not working in the unit tests
#
# # Act
# step = DownloadFileStep(url=URL, download_path=download_path, mode="ignore")
# step.log.setLevel("INFO")
# step.execute()
# print(f"2 {caplog.record_tuples = }")
#
# # Assert
# print(f"5 {caplog.text = }")
# assert "Ignoring testfile.txt based on IGNORE mode." in caplog.text
#
# print(f"3 {caplog.text = }")
# assert downloaded_file.exists()
# print(f"4 {caplog.text = }")
# assert downloaded_file.read_bytes() == b"foo"

# Assert
assert "Ignoring testfile.txt based on IGNORE mode." in caplog.text
assert downloaded_file.exists()
assert downloaded_file.read_bytes() == b"foo"

def test_download_file_step_exclusive_mode(self, download_path, downloaded_file):
"""In EXCLUSIVE mode, an error should be raised if the file exists"""
Expand Down

0 comments on commit c031ae8

Please sign in to comment.