-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * minor changes to .gitignore * minor fixes * WIP * fix: correct tests imports * WIP * Fix test path issues * Polish tests * Fix mypy * Polish Index.md * Polish Index.md * Fix typo * Lint * Fix test --------- Co-authored-by: Davor Runje <[email protected]> Co-authored-by: Lancetnik <[email protected]>
- Loading branch information
1 parent
8a813a1
commit 7886574
Showing
9 changed files
with
126 additions
and
24 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
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,15 @@ | ||
import contextlib | ||
import os | ||
from pathlib import Path | ||
from typing import Generator | ||
|
||
|
||
@contextlib.contextmanager | ||
def working_directory(path: str) -> Generator[None, None, None]: | ||
"""Changes working directory and returns to previous on exit.""" | ||
prev_cwd = Path.cwd() | ||
os.chdir(path) | ||
try: | ||
yield | ||
finally: | ||
os.chdir(prev_cwd) |
Empty file.
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 |
---|---|---|
@@ -1,3 +1,37 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from docs_src.kafka.base_example.testing import test_base_app | ||
from docs_src.kafka.base_example.testing_chain import test_end_to_end | ||
from faststream.utils.test_utils import working_directory | ||
|
||
__all__ = ( | ||
"test_run_cmd", | ||
"test_end_to_end", | ||
"test_base_app", | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_run_cmd(request): | ||
rootdir = request.config.rootdir | ||
with working_directory(rootdir / "docs_src/kafka/base_example"): | ||
cmd = "faststream run app:app" | ||
|
||
proc = await asyncio.create_subprocess_exec( | ||
*cmd.split(" "), | ||
stdout=asyncio.subprocess.PIPE, | ||
stderr=asyncio.subprocess.PIPE, | ||
) | ||
|
||
await asyncio.sleep(10) | ||
|
||
proc.terminate() | ||
|
||
stdout, stderr = await proc.communicate() | ||
stdout.decode("utf-8") | ||
dstderr = stderr.decode("utf-8") | ||
|
||
__all__ = ("test_base_app",) | ||
assert "FastStream app starting..." in dstderr | ||
assert "FastStream app started successfully! To exit press CTRL+C" in dstderr |
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,3 @@ | ||
from docs_src.kafka.base_example.testing_chain import test_end_to_end | ||
|
||
__all__ = ("test_end_to_end",) |