Add initial cli test
This commit is contained in:
parent
97035d8e4c
commit
2d2b4430ff
5 changed files with 12 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
testdata/
|
||||
data/
|
||||
output.db
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,python,pandas
|
||||
|
|
|
@ -13,6 +13,7 @@ python = "^3.9"
|
|||
click = "^8.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^6.2"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
habitmove = "habitmove.cli:main"
|
||||
|
|
|
@ -9,9 +9,6 @@ import click
|
|||
from . import __version__
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def migrate(data: NomieImport):
|
||||
db = schema.migrate("output.db")
|
||||
if not db:
|
||||
|
@ -32,8 +29,6 @@ def migrate(data: NomieImport):
|
|||
@click.version_option(version=__version__)
|
||||
@click.argument("inputfile")
|
||||
def main(inputfile):
|
||||
# TODO test and error gracefully for no input given
|
||||
# file = sys.argv[1]
|
||||
data = nomie.get_data(inputfile)
|
||||
migrate(data)
|
||||
|
||||
|
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
10
tests/test_cli.py
Normal file
10
tests/test_cli.py
Normal 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
|
Loading…
Reference in a new issue