feat: add wutta
top-level command with make-uuid
subcommand
i think it only makes sense to have an "opinion" for command line interface in this project, and we probably need more `wutta` subcommands too but we'll see. main motivation for this currently is to allow poser apps to define their own CLI, in particular e.g. `poser install`
This commit is contained in:
parent
cb147c203d
commit
2deba45588
20 changed files with 446 additions and 47 deletions
0
tests/cli/__init__.py
Normal file
0
tests/cli/__init__.py
Normal file
0
tests/cli/example.conf
Normal file
0
tests/cli/example.conf
Normal file
39
tests/cli/test_base.py
Normal file
39
tests/cli/test_base.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import typer
|
||||
|
||||
from wuttjamaican.conf import WuttaConfig
|
||||
from wuttjamaican.cli import base as mod
|
||||
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
example_conf = os.path.join(here, 'example.conf')
|
||||
|
||||
|
||||
class TestMakeCliConfig(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
ctx = MagicMock(params={'config_paths': [example_conf]})
|
||||
config = mod.make_cli_config(ctx)
|
||||
self.assertIsInstance(config, WuttaConfig)
|
||||
self.assertEqual(config.files_read, [example_conf])
|
||||
|
||||
|
||||
class TestTyperCallback(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
ctx = MagicMock(params={'config_paths': [example_conf]})
|
||||
mod.typer_callback(ctx)
|
||||
self.assertIsInstance(ctx.wutta_config, WuttaConfig)
|
||||
self.assertEqual(ctx.wutta_config.files_read, [example_conf])
|
||||
|
||||
|
||||
class TestMakeTyper(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
typr = mod.make_typer()
|
||||
self.assertIsInstance(typr, typer.Typer)
|
20
tests/cli/test_make_uuid.py
Normal file
20
tests/cli/test_make_uuid.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from wuttjamaican.cli import make_uuid as mod
|
||||
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
example_conf = os.path.join(here, 'example.conf')
|
||||
|
||||
|
||||
class TestMakeUuid(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
ctx = MagicMock(params={'config_paths': [example_conf]})
|
||||
with patch.object(mod, 'sys') as sys:
|
||||
mod.make_uuid(ctx)
|
||||
sys.stdout.write.assert_called_once()
|
Loading…
Add table
Add a link
Reference in a new issue