kopia lustrzana https://github.com/jedie/PyInventory
Bugfix devshell "manage" command
rodzic
2a74d85857
commit
3377c12451
|
@ -54,7 +54,7 @@ class PyInventoryCommandSet(DevShellBaseCommandSet):
|
|||
"""
|
||||
Call PyInventory test "manage.py"
|
||||
"""
|
||||
call_manage_py(*statement.arg_list, cwd=PACKAGE_ROOT / 'src' / 'inventory')
|
||||
call_manage_py(*statement.arg_list, cwd=PACKAGE_ROOT)
|
||||
|
||||
def do_run_testserver(self, statement: cmd2.Statement):
|
||||
"""
|
||||
|
|
|
@ -11,27 +11,32 @@ import inventory
|
|||
BASE_PATH = Path(inventory.__file__).parent.parent.parent
|
||||
|
||||
|
||||
def call_run_testserver(*args):
|
||||
def call_devshell_commands(*args):
|
||||
dev_shell_py = BASE_PATH / 'devshell.py'
|
||||
assert_is_file(dev_shell_py)
|
||||
output = subprocess.check_output(
|
||||
[sys.executable, str(dev_shell_py), 'run_testserver'] + list(args),
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
[sys.executable, str(dev_shell_py)] + list(args), stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
return output
|
||||
|
||||
|
||||
class RunTestServerTestCase(TestCase):
|
||||
class DevShellTestCase(TestCase):
|
||||
def test_run_testserver(self):
|
||||
output = call_run_testserver('--help')
|
||||
output = call_devshell_commands('run_testserver', '--help')
|
||||
assert 'usage: manage.py run_testserver' in output
|
||||
assert 'Run Django dev. Server' in output
|
||||
assert 'Optional port number, or ipaddr:port' in output
|
||||
|
||||
def test_pass_wrong_addrport(self):
|
||||
output = call_run_testserver('not-ip:no-port')
|
||||
output = call_devshell_commands('run_testserver', 'not-ip:no-port')
|
||||
assert "call 'runserver' command with" in output
|
||||
assert (
|
||||
'CommandError: "not-ip:no-port" is not a valid port number or address:port pair.'
|
||||
) in output
|
||||
|
||||
def test_manage_command(self):
|
||||
output = call_devshell_commands('manage', 'diffsettings')
|
||||
assert "DJANGO_SETTINGS_MODULE='inventory_project.settings.tests'" in output
|
||||
assert f"PROJECT_PATH:{BASE_PATH}/src" in output
|
||||
assert f"BASE_PATH:{BASE_PATH}" in output
|
||||
assert f"PROJECT_PATH = PosixPath('{BASE_PATH}/src')" in output
|
Ładowanie…
Reference in New Issue