Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Add Unit Test #170

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/unit/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
from pathlib import Path
from tempfile import NamedTemporaryFile

from typer.testing import CliRunner

Expand Down Expand Up @@ -36,6 +37,13 @@ def test_account_export_private_key(account_file: Path):
assert len(result.stdout.strip()) == 66


def test_account_path():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this testing ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test check that path is set well

result = runner.invoke(
app, ["account", "path"]
)
assert result.stdout.startswith("/")


def test_message_get():
# Use subprocess to avoid border effects between tests caused by the initialisation
# of the aiohttp client session out of an async context in the SDK. This avoids
Expand Down Expand Up @@ -73,3 +81,19 @@ def test_message_find():
b"bd79839bf96e595a06da5ac0b6ba51dea6f7e2591bb913deccded04d831d29f4"
in result.stdout
)


def test_file_upload():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a docstring that explains what this is testing ?

with NamedTemporaryFile() as temp_file:
temp_file.write(b"Hello World \n")
result = subprocess.run(
[
"aleph",
"file",
"upload",
temp_file.name
],
capture_output=True,
)
assert result.returncode == 0
assert result.stdout is not None