Add initial cli test

This commit is contained in:
Marty Oehme 2021-12-06 23:20:18 +01:00
parent 97035d8e4c
commit 2d2b4430ff
Signed by: Marty
GPG key ID: B7538B8F50A1C800
5 changed files with 12 additions and 6 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
testdata/ data/
output.db output.db
# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,python,pandas # Created by https://www.toptal.com/developers/gitignore/api/vim,linux,python,pandas

View file

@ -13,6 +13,7 @@ python = "^3.9"
click = "^8.0" click = "^8.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "^6.2"
[tool.poetry.scripts] [tool.poetry.scripts]
habitmove = "habitmove.cli:main" habitmove = "habitmove.cli:main"

View file

@ -9,9 +9,6 @@ import click
from . import __version__ from . import __version__
import sys
def migrate(data: NomieImport): def migrate(data: NomieImport):
db = schema.migrate("output.db") db = schema.migrate("output.db")
if not db: if not db:
@ -32,8 +29,6 @@ def migrate(data: NomieImport):
@click.version_option(version=__version__) @click.version_option(version=__version__)
@click.argument("inputfile") @click.argument("inputfile")
def main(inputfile): def main(inputfile):
# TODO test and error gracefully for no input given
# file = sys.argv[1]
data = nomie.get_data(inputfile) data = nomie.get_data(inputfile)
migrate(data) migrate(data)

0
tests/__init__.py Normal file
View file

10
tests/test_cli.py Normal file
View file

@ -0,0 +1,10 @@
import click.testing
from habitmove import cli
def test_cli_fails_without_file():
runner = click.testing.CliRunner()
result = runner.invoke(cli.main)
assert result.exit_code == 2
assert "Missing argument" in result.output