mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
new system tests
This commit is contained in:
+4
-35
@@ -1,38 +1,7 @@
|
||||
import _io
|
||||
from io import StringIO
|
||||
from unittest.mock import patch, MagicMock
|
||||
import io
|
||||
from argenta.app import App
|
||||
from argenta.command import Command
|
||||
from argenta.router import Router
|
||||
import re
|
||||
|
||||
|
||||
def run_shell():
|
||||
router = Router()
|
||||
|
||||
@router.command(Command('test'))
|
||||
def test():
|
||||
print('loh ibanu')
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
|
||||
app.start_polling()
|
||||
|
||||
|
||||
@patch("builtins.input", side_effect=["test", "q"])
|
||||
@patch("sys.stdout", new_callable=io.StringIO)
|
||||
def test_run_shell_output(mock_stdout: _io.StringIO, magick_mock: MagicMock):
|
||||
run_shell()
|
||||
output = mock_stdout.getvalue()
|
||||
|
||||
assert "loh ibanu" in output
|
||||
return magick_mock
|
||||
|
||||
|
||||
res = test_run_shell_output()
|
||||
print(res)
|
||||
print(type(res))
|
||||
|
||||
print("✅ Тест вывода пройден!")
|
||||
def test(string):
|
||||
return bool(re.match(r'\ntest command\n(.|\s)*\nsome command\n', string))
|
||||
|
||||
print(test('test command tpgm4tigm4tigmt\n i0hhmi6h some command'))
|
||||
|
||||
Reference in New Issue
Block a user