-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interactive mode integration test
- Loading branch information
Showing
22 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Fixtures providing common values for integration tests.""" | ||
|
||
from datetime import datetime, timezone | ||
from pathlib import Path | ||
import pytest | ||
|
||
from goth.project import PROJECT_ROOT | ||
|
||
|
||
@pytest.fixture | ||
def log_dir() -> Path: | ||
"""Return path to dir where goth test session logs should be placed.""" | ||
base_dir = Path("/", "tmp", "goth-tests") | ||
date_str = datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S%z") | ||
log_dir = base_dir / f"goth_{date_str}" | ||
log_dir.mkdir(parents=True) | ||
return log_dir | ||
|
||
|
||
@pytest.fixture | ||
def default_goth_config() -> Path: | ||
"""Return path to default `goth-config.yml` file.""" | ||
return PROJECT_ROOT / "goth" / "default-assets" / "goth-config.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Integration tests for the goth interactive mode.""" | ||
|
||
import asyncio | ||
from pathlib import Path | ||
import pytest | ||
|
||
from goth.configuration import load_yaml | ||
from goth.interactive import start_network, env_file | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_interactive( | ||
capsys: pytest.CaptureFixture, default_goth_config: Path, log_dir: Path | ||
) -> None: | ||
"""Test if goth interactive mode launches correctly.""" | ||
goth_config = load_yaml(default_goth_config, []) | ||
interactive_task = asyncio.create_task(start_network(goth_config, log_dir)) | ||
|
||
async def _scan_stdout(): | ||
expected_msg = "Local goth network ready" | ||
while True: | ||
stdout, _stderr = capsys.readouterr() | ||
if expected_msg in stdout: | ||
break | ||
await asyncio.sleep(0.1) | ||
|
||
try: | ||
await asyncio.wait_for(_scan_stdout(), timeout=90) | ||
assert env_file.exists() | ||
except asyncio.TimeoutError: | ||
pytest.fail("Timeout while waiting for interactive mode to start") | ||
finally: | ||
interactive_task.cancel() | ||
await interactive_task |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.