Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

sys.path.append(f"{Path(__file__).parent.parent}/src")

READABLE_TEST_OUTPUT = not any("neotest" in arg for arg in sys.argv)


def pytest_html_report_title(report):
report.title = "Rubie Gateway Tests"
Expand Down Expand Up @@ -49,7 +51,7 @@ def pytest_runtest_makereport(item, call):
report = outcome.get_result()

readable_name = _readable_test_name(item)
if readable_name:
if readable_name and READABLE_TEST_OUTPUT:
report.nodeid = readable_name


Expand All @@ -66,7 +68,7 @@ def mock_azure_credential():

@pytest.fixture
def tmp_dir():
return f"{Path(__file__).parent}/tmp"
return Path(__file__).parent / "tmp"


@pytest.fixture(autouse=True)
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_pacs_storage_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@


@pytest.fixture
def mwl_storage(tmp_path):
def mwl_storage(tmp_dir):
"""Create MWLStorage instance with temp database."""
return MWLStorage(db_path=f"{tmp_path}/worklist.db")
return MWLStorage(db_path=f"{tmp_dir}/worklist.db")


@pytest.fixture
def pacs_storage(tmp_path):
def pacs_storage(tmp_dir):
"""Create PACSStorage instance with temp database."""
return PACSStorage(db_path=f"{tmp_path}/pacs.db", storage_root=str(tmp_path / "storage"))
return PACSStorage(db_path=f"{tmp_dir}/pacs.db", storage_root=f"{tmp_dir}/storage")


class TestPACSStorageUpload:
Expand Down
23 changes: 11 additions & 12 deletions tests/scripts/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@


@pytest.fixture
def sqlite_db(tmp_path):
db_path = tmp_path / "test.db"
def backup_dir(tmp_dir):
return tmp_dir / "backups"


@pytest.fixture
def sqlite_db(tmp_dir):
db_path = tmp_dir / "test.db"

conn = sqlite3.connect(db_path)

Expand Down Expand Up @@ -45,12 +50,11 @@ def row_count(db_path, table):


def test_backup_and_reset_creates_backup(
tmp_path,
backup_dir,
sqlite_db,
monkeypatch,
):
"""Backup database creates backup."""
backup_dir = tmp_path / "backups"
monkeypatch.setenv("DB_PATH", str(sqlite_db))
monkeypatch.setenv("TABLE_NAME", "stored_instances")
monkeypatch.setenv("BACKUP_PATH", str(backup_dir))
Expand All @@ -71,12 +75,11 @@ def test_backup_and_reset_creates_backup(


def test_rotation_keeps_five_backups(
tmp_path,
backup_dir,
sqlite_db,
monkeypatch,
):
"""Only 5 database backups are kept and older ones are deleted."""
backup_dir = tmp_path / "backups"
monkeypatch.setenv("DB_PATH", str(sqlite_db))
monkeypatch.setenv("TABLE_NAME", "stored_instances")
monkeypatch.setenv("BACKUP_PATH", str(backup_dir))
Expand Down Expand Up @@ -110,13 +113,11 @@ def test_rotation_keeps_five_backups(


def test_newest_backup_is_backup_zero(
tmp_path,
backup_dir,
sqlite_db,
monkeypatch,
):
"""Newest backup is always backup.0."""
backup_dir = tmp_path / "backups"

monkeypatch.setenv("DB_PATH", str(sqlite_db))
monkeypatch.setenv("TABLE_NAME", "stored_instances")
monkeypatch.setenv("BACKUP_PATH", str(backup_dir))
Expand All @@ -141,13 +142,11 @@ def test_newest_backup_is_backup_zero(


def test_invalid_table_name_is_ignored(
tmp_path,
backup_dir,
sqlite_db,
monkeypatch,
):
"""Invalid table name is ignored."""
backup_dir = tmp_path / "backups"

monkeypatch.setenv("DB_PATH", str(sqlite_db))
monkeypatch.setenv("TABLE_NAME", "users")
monkeypatch.setenv("BACKUP_PATH", str(backup_dir))
Expand Down
6 changes: 3 additions & 3 deletions tests/services/mwl/test_create_worklist_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class TestCreateWorklistItem:
@pytest.fixture
def db_file(tmp_path):
return f"{tmp_path}/test.db"
def db_file(self, tmp_dir):
return tmp_dir / "test.db"

@pytest.fixture
def mwl_storage(self, db_file):
return MWLStorage(str(db_file))
return MWLStorage(db_file)

def test_call_success(self, mwl_storage, listener_payload):
"""Create worklist item: Call success."""
Expand Down
4 changes: 2 additions & 2 deletions tests/services/mwl/test_update_worklist_item_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def status_update_payload(self):
}

@pytest.fixture
def db_file(self, tmp_path) -> str:
return f"{tmp_path}/test.db"
def db_file(self, tmp_dir) -> str:
return tmp_dir / "test.db"

@pytest.fixture
def mwl_storage(self, db_file: str):
Expand Down
8 changes: 4 additions & 4 deletions tests/services/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@


@pytest.fixture
def db_file(tmp_path):
return tmp_path / "test.db"
def db_file(tmp_dir):
return tmp_dir / "test.db"


@pytest.fixture
def pacs_storage(db_file, tmp_path):
storage = PACSStorage(str(db_file), str(tmp_path))
def pacs_storage(db_file, tmp_dir):
storage = PACSStorage(str(db_file), str(tmp_dir))
return storage


Expand Down
Loading