def test_custom_command_with_int_arguments(): def add(a: int, b: int) -> None: click.echo(str(a + b)) app = App(commands=[add]) runner = CommandLineRunner(app) result = runner.invoke([]) assert 'add' in result.output result = runner.invoke(['add', '1', '2']) assert result.output == '3\n' assert result.exit_code == 0
def test_custom_command_with_int_arguments(): def add(a: int, b: int): click.echo(str(a + b)) app = App(commands=[add]) runner = CommandLineRunner(app) result = runner.invoke([]) assert 'add' in result.output result = runner.invoke(['add', '1', '2']) assert result.output == '3\n' assert result.exit_code == 0
def test_custom_command(): def custom(var): click.echo(var) app = App(commands=[custom]) runner = CommandLineRunner(app) result = runner.invoke([]) assert 'custom' in result.output result = runner.invoke(['custom', '123']) assert result.output == '123\n' assert result.exit_code == 0
return created_kitten app = App(routes=[ routing.Route('/kittens/create/', 'GET', create_kitten), routing.Route('/kittens/', 'GET', list_kittens), ], settings={ "DATABASE": { "URL": environ.get('DB_URL', 'sqlite:///test.db'), "METADATA": Base.metadata } }) client = test.TestClient(app) runner = CommandLineRunner(app) @pytest.fixture def clear_db(scope="function"): yield db_backend = SQLAlchemy.build(app.settings) db_backend.drop_tables() def test_list_create(monkeypatch, clear_db): def mock_get_current_app(): return app monkeypatch.setattr(apistar.cli, 'get_current_app', mock_get_current_app)