3
0
Fork 0

Move cli framework to wuttjamaican.cmd subpackage

deprecate `wuttjamaican.commands`
This commit is contained in:
Lance Edgar 2023-11-22 11:13:39 -06:00
parent 37e42eebbc
commit c3914738d5
23 changed files with 753 additions and 598 deletions

View file

@ -5,11 +5,15 @@ import sys
from unittest import TestCase
from unittest.mock import MagicMock, patch
from wuttjamaican.commands import base
from wuttjamaican.commands.setup import Setup
from wuttjamaican.cmd import base
from wuttjamaican.cmd.setup import Setup
from wuttjamaican.testing import FileConfigTestCase
# nb. do this just for coverage
from wuttjamaican.commands.base import Command as legacy
class TestCommand(FileConfigTestCase):
def test_base(self):
@ -20,7 +24,7 @@ class TestCommand(FileConfigTestCase):
self.assertEqual(str(cmd), 'wutta')
def test_subcommand_entry_points(self):
with patch('wuttjamaican.commands.base.load_entry_points') as load_entry_points:
with patch('wuttjamaican.cmd.base.load_entry_points') as load_entry_points:
# empty entry points
load_entry_points.side_effect = lambda group: {}
@ -144,7 +148,7 @@ class TestCommand(FileConfigTestCase):
self.stdout.write("hello world")
self.stderr.write("error text")
with patch('wuttjamaican.commands.base.sys') as sys:
with patch('wuttjamaican.cmd.base.sys') as sys:
cmd = base.Command(subcommands={'hello': Hello})
@ -226,7 +230,7 @@ class TestMain(TestCase):
def true_exit(*args):
sys.exit(*args)
with patch('wuttjamaican.commands.base.sys') as mocksys:
with patch('wuttjamaican.cmd.base.sys') as mocksys:
mocksys.argv = ['wutta', '--help']
mocksys.exit = true_exit

View file

@ -7,7 +7,11 @@ from unittest import TestCase
from unittest.mock import patch
from wuttjamaican.conf import WuttaConfig
from wuttjamaican.commands import Command, make_appdir
from wuttjamaican.cmd import Command, make_appdir
# nb. do this just for coverage
from wuttjamaican.commands.make_appdir import MakeAppDir as legacy
class TestMakeAppDir(TestCase):
@ -38,7 +42,7 @@ class TestMakeAppDir(TestCase):
shutil.rmtree(tempdir)
# mock out sys.prefix to get coverage
with patch('wuttjamaican.commands.make_appdir.sys') as sys:
with patch('wuttjamaican.cmd.make_appdir.sys') as sys:
tempdir = tempfile.mkdtemp()
appdir = os.path.join(tempdir, 'app')
sys.prefix = tempdir

View file

@ -2,7 +2,11 @@
from unittest import TestCase
from wuttjamaican.commands import setup, Command
from wuttjamaican.cmd import Command, setup
# nb. do this just for coverage
from wuttjamaican.commands.setup import Setup as legacy
class TestSetup(TestCase):