mirror of
https://github.com/ihabunek/toot
synced 2024-12-22 23:08:17 +01:00
Extend instance tests
This commit is contained in:
parent
6c9b939175
commit
e5c8fc4f77
@ -24,9 +24,6 @@ from click.testing import CliRunner, Result
|
||||
from pathlib import Path
|
||||
from toot import api, App, User
|
||||
from toot.cli import Context
|
||||
from toot.console import run_command
|
||||
from toot.exceptions import ApiError, ConsoleError
|
||||
from toot.output import print_out
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
@ -36,6 +33,7 @@ def pytest_configure(config):
|
||||
|
||||
# Mastodon database name, used to confirm user registration without having to click the link
|
||||
DATABASE_DSN = os.getenv("TOOT_TEST_DATABASE_DSN")
|
||||
TOOT_TEST_BASE_URL = os.getenv("TOOT_TEST_BASE_URL")
|
||||
|
||||
# Toot logo used for testing image upload
|
||||
TRUMPET = str(Path(__file__).parent.parent.parent / "trumpet.png")
|
||||
@ -74,12 +72,10 @@ def confirm_user(email):
|
||||
# DO NOT USE PUBLIC INSTANCES!!!
|
||||
@pytest.fixture(scope="session")
|
||||
def base_url():
|
||||
base_url = os.getenv("TOOT_TEST_BASE_URL")
|
||||
|
||||
if not base_url:
|
||||
if not TOOT_TEST_BASE_URL:
|
||||
pytest.skip("Skipping integration tests, TOOT_TEST_BASE_URL not set")
|
||||
|
||||
return base_url
|
||||
return TOOT_TEST_BASE_URL
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@ -119,9 +115,9 @@ def runner():
|
||||
|
||||
@pytest.fixture
|
||||
def run(app, user, runner):
|
||||
def _run(command, *params, as_user=None) -> Result:
|
||||
def _run(command, *params, as_user=None, input=None) -> Result:
|
||||
ctx = Context(app, as_user or user)
|
||||
return runner.invoke(command, params, obj=ctx)
|
||||
return runner.invoke(command, params, obj=ctx, input=input)
|
||||
return _run
|
||||
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
from tests.integration.conftest import TOOT_TEST_BASE_URL
|
||||
from toot import api, cli
|
||||
from toot.entities import Account, Status, from_dict, from_dict_list
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
def test_instance(app, run):
|
||||
def test_instance_default(app, run):
|
||||
result = run(cli.instance)
|
||||
assert result.exit_code == 0
|
||||
|
||||
@ -15,6 +16,15 @@ def test_instance(app, run):
|
||||
assert "running Mastodon" in result.stdout
|
||||
|
||||
|
||||
def test_instance_with_url(app, run):
|
||||
result = run(cli.instance, TOOT_TEST_BASE_URL)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "Mastodon" in result.stdout
|
||||
assert app.instance in result.stdout
|
||||
assert "running Mastodon" in result.stdout
|
||||
|
||||
|
||||
def test_instance_json(app, run):
|
||||
result = run(cli.instance, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
Loading…
Reference in New Issue
Block a user