Skip to content

Commit

Permalink
removed tests with tmpdir from unit-tests.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottekostelic committed Jul 11, 2024
1 parent aa1e141 commit 234e958
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -r dev-requirements.txt
- name: Run tests
run: pytest -m "not livetest" --cov=file_retriever/
run: pytest -m "not livetest and not tmpdir" --cov=file_retriever/
- name: Send report to Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ temp.*
tests/creds.yaml
envar*.yaml
config.yaml
creds.yaml
creds.yaml
temp/*
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pytest-cov = "^5.0.0"
[tool.pytest.ini_options]
testpaths = ["tests"]
markers = [
"livetest: mark a test as hitting a live ftp/sftp server"
"livetest: mark a test as hitting a live ftp/sftp server",
"tmpdir: mark a test as using the pytest tmpdir fixture",
]


Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def mock_creds() -> Dict[str, str]:


@pytest.fixture
def test_vendor_dst_dir() -> Generator:
def test_dst_dir() -> Generator:
dst = "tests/dst_dir/"
if not os.path.exists(dst):
os.makedirs(dst)
Expand Down
10 changes: 6 additions & 4 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def test_ConnectionClient_list_files(
assert files == file_list


@pytest.mark.tmpdir
@pytest.mark.parametrize("port", [21, 22])
def test_ConnectionClient_get_files_to_tmpdir(tmpdir, stub_client, mock_creds, port):
mock_creds["port"] = port
Expand All @@ -71,17 +72,18 @@ def test_ConnectionClient_get_files_to_tmpdir(tmpdir, stub_client, mock_creds, p
assert all_files == ["foo.mrc"]


@pytest.mark.tmpdir
@pytest.mark.parametrize("port", [21, 22])
def test_ConnectionClient_get_files_to_vendor_dst_dir(
test_vendor_dst_dir, stub_client, mock_creds, port
def test_ConnectionClient_get_files_to_tmpdir_dst_dir(
test_dst_dir, stub_client, mock_creds, port
):
mock_creds["port"] = port
mock_creds["dst_dir"] = "tests/dst_dir/"
connect = ConnectionClient(**mock_creds)
new_files = connect.get_files(time_delta=1)
new_files_count = len(os.listdir(test_vendor_dst_dir))
new_files_count = len(os.listdir(test_dst_dir))
old_files = connect.get_files(time_delta=20)
old_files_count = len(os.listdir(test_vendor_dst_dir))
old_files_count = len(os.listdir(test_dst_dir))
assert new_files_count == 0
assert old_files_count == 1
assert new_files == []
Expand Down

0 comments on commit 234e958

Please sign in to comment.