From aa541de52fc26ea1cd57b0972f29591ba3b89992 Mon Sep 17 00:00:00 2001 From: Daniel Brummerloh Date: Wed, 13 Dec 2023 17:01:56 +0100 Subject: [PATCH] add tests for dirmanager --- tests/test_dir_manager.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_dir_manager.py diff --git a/tests/test_dir_manager.py b/tests/test_dir_manager.py new file mode 100644 index 0000000..8dd78b1 --- /dev/null +++ b/tests/test_dir_manager.py @@ -0,0 +1,30 @@ + +import time +import pytest +from pytest_abra.dir_manager import DirManager +from pathlib import Path + +def test_get_latest_session_id_from_non_existing_dir(tmp_path: Path): + out = DirManager.get_latest_session_id(tmp_path / "not_exist") + assert out is None + +def test_get_latest_session_id_from_empty_dir(tmp_path: Path): + out = DirManager.get_latest_session_id(tmp_path) + assert out is None + +def test_get_latest_session_id_single(tmp_path: Path): + (tmp_path / "a").mkdir() + out = DirManager.get_latest_session_id(tmp_path) + assert out == "a" + + + +@pytest.mark.slow +def test_get_latest_session_id(tmp_path: Path): + (tmp_path / "a").mkdir() + time.sleep(1.1) + (tmp_path / "b").mkdir() + out = DirManager.get_latest_session_id(tmp_path) + assert out == "b" + + \ No newline at end of file