Skip to content

Commit

Permalink
Fix test which expects full database to be defined
Browse files Browse the repository at this point in the history
  • Loading branch information
evansd committed Sep 12, 2023
1 parent 676aaec commit 6bf3f43
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def add_maintenance_command(mock_subprocess_run, current):
)


def test_maintenance_mode_off(mock_subprocess_run, db):
def test_maintenance_mode_off(mock_subprocess_run, db, db_config):
ps = add_maintenance_command(mock_subprocess_run, current=None)
ps.stdout = ""
assert service.maintenance_mode() is None
Expand All @@ -70,7 +70,7 @@ def test_maintenance_mode_off(mock_subprocess_run, db):
assert service.maintenance_mode() is None


def test_maintenance_mode_on(mock_subprocess_run, db):
def test_maintenance_mode_on(mock_subprocess_run, db, db_config):
ps = add_maintenance_command(mock_subprocess_run, current=None)
ps.stdout = "db-maintenance"
ps.stderr = "other stuff"
Expand All @@ -83,11 +83,16 @@ def test_maintenance_mode_on(mock_subprocess_run, db):
assert service.maintenance_mode() == "db-maintenance"


def test_maintenance_mode_error(mock_subprocess_run, db):
def test_maintenance_mode_error(mock_subprocess_run, db, db_config):
ps = add_maintenance_command(mock_subprocess_run, current=None)
ps.returncode = 1
ps.stdout = ""
ps.stderr = "error"

with pytest.raises(subprocess.CalledProcessError):
service.maintenance_mode()


@pytest.fixture
def db_config(monkeypatch):
monkeypatch.setitem(config.DATABASE_URLS, "full", "mssql://localhost")

0 comments on commit 6bf3f43

Please sign in to comment.