Skip to content

Commit

Permalink
Fake config file for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Jun 10, 2024
1 parent 0ef5ec1 commit 1d4a185
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ def polldevs_conf_with_no_routers(tmp_path):
yield name


@pytest.fixture
def zino_default_conf(tmp_path):
name = tmp_path / "zino.toml"
with open(name, "w") as conf:
conf.write(
"""
old_events = "old-events"
zino_secrets = "secrets"
persist_file = "zino-state.json"
persist_period = 5
conf_check = 1
"""
)
yield name


@pytest.fixture(scope="session")
def event_loop():
"""Redefine pytest-asyncio's event_loop fixture to have a session scope"""
Expand Down
8 changes: 5 additions & 3 deletions tests/zino_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_zino_help_screen_should_not_crash():
assert subprocess.check_call(["zino", "--help"]) == 0


def test_zino_should_not_crash_right_away(polldevs_conf_with_no_routers):
def test_zino_should_not_crash_right_away(polldevs_conf_with_no_routers, zino_default_conf):
"""This tests that the main function runs Zino for at least 2 seconds"""
seconds_to_run_for = 2
subprocess.check_call(
Expand All @@ -36,14 +36,16 @@ def test_zino_should_not_crash_right_away(polldevs_conf_with_no_routers):
str(seconds_to_run_for),
"--polldevs",
str(polldevs_conf_with_no_routers),
"--config-file",
str(zino_default_conf),
"--trap-port",
"1162",
]
)


def test_zino_argparser_works(polldevs_conf):
parser = zino.parse_args(["--polldevs", str(polldevs_conf)])
def test_zino_argparser_works(polldevs_conf, zino_default_conf):
parser = zino.parse_args(["--polldevs", str(polldevs_conf), "--config-file", str(zino_default_conf)])
assert isinstance(parser, Namespace)


Expand Down

0 comments on commit 1d4a185

Please sign in to comment.