Skip to content

Commit

Permalink
Test aleph program logs command
Browse files Browse the repository at this point in the history
  • Loading branch information
olethanh committed Dec 16, 2024
1 parent 2a6935f commit 44af4e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/unit/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import contextlib
import json
from pathlib import Path
from tempfile import NamedTemporaryFile
from unittest.mock import AsyncMock, patch

from aleph.sdk.chains.ethereum import ETHAccount
from aleph.sdk.conf import settings
Expand Down Expand Up @@ -293,3 +295,37 @@ def test_file_download():
)
assert result.exit_code == 0
assert result.stdout is not None


def test_app():
@contextlib.asynccontextmanager
async def m(self, vm_id, operation, method="GET"):
try:
yield AsyncMock(
url="http://",
status=200,
json=AsyncMock(
return_value=[
{
"__REALTIME_TIMESTAMP": "2024-02-02 23:34:21",
"MESSAGE": "hello world",
}
]
),
)
finally:
pass

with patch("aleph_client.commands.program.VmClient.operate", m):
result = runner.invoke(
app,
[
"program",
"logs",
"--domain",
"http://localhost:4200",
"decadecadecadecadecadecadecadecadecadecadecadecadecadecadecadeca",
],
)
assert result.exit_code == 0, result.stdout
assert result.stdout == "Received logs\n2024-02-02 23:34:21> hello world\n"

0 comments on commit 44af4e9

Please sign in to comment.