From 267f363bc45e77e535967d0cc54d05d580909ddd Mon Sep 17 00:00:00 2001 From: phil-bell Date: Fri, 11 Mar 2022 13:40:33 +0000 Subject: [PATCH 1/2] adding shell command --- legl_dev/main.py | 7 +++++++ legl_dev/tests/test_main.py | 40 +++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/legl_dev/main.py b/legl_dev/main.py index a9f441f..be44a1f 100755 --- a/legl_dev/main.py +++ b/legl_dev/main.py @@ -309,6 +309,13 @@ def install( steps.run() +@app.command(help="Remote into a container") +def shell(environment: Optional[str] = typer.Argument(default="backend", help="Container to remote into")): + steps = Steps() + steps.add( + Command(command=f"docker compose exec {environment} bash") + ) + steps.run() @app.callback() def main(version: bool = False): diff --git a/legl_dev/tests/test_main.py b/legl_dev/tests/test_main.py index 1547dc2..4286038 100644 --- a/legl_dev/tests/test_main.py +++ b/legl_dev/tests/test_main.py @@ -159,3 +159,43 @@ def test_install_self_upgrade(run): ), ] run.assert_has_calls(calls) + + +@mock.patch("legl_dev.command.run") +def test_remote_no_commands(run): + main.remote() + calls = [ + mock.call( + ["docker", "compose", "exe", "backend", "bash"], + universal_newlines=True, + shell=False, + check=True, + ), + ] + run.assert_has_calls(calls) + +@mock.patch("legl_dev.command.run") +def test_remote_frontend_commands(run): + main.remote("frontend") + calls = [ + mock.call( + ["docker", "compose", "exe", "frontend", "bash"], + universal_newlines=True, + shell=False, + check=True, + ), + ] + run.assert_has_calls(calls) + +@mock.patch("legl_dev.command.run") +def test_remote_frontend_commands(run): + main.remote("frontend") + calls = [ + mock.call( + ["docker", "compose", "exe", "frontend", "bash"], + universal_newlines=True, + shell=False, + check=True, + ), + ] + run.assert_has_calls(calls) diff --git a/setup.py b/setup.py index 7705eb8..aed7fd5 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from setuptools import setup -version = "1.1.2" +version = "1.2.0" packages = ["legl_dev"] From 4aecc50150389393114cfcc7b24db349a68237f6 Mon Sep 17 00:00:00 2001 From: phil-bell Date: Fri, 11 Mar 2022 13:48:22 +0000 Subject: [PATCH 2/2] fixing tests and removing default test --- legl_dev/tests/test_main.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/legl_dev/tests/test_main.py b/legl_dev/tests/test_main.py index 4286038..845c7a1 100644 --- a/legl_dev/tests/test_main.py +++ b/legl_dev/tests/test_main.py @@ -160,26 +160,12 @@ def test_install_self_upgrade(run): ] run.assert_has_calls(calls) - -@mock.patch("legl_dev.command.run") -def test_remote_no_commands(run): - main.remote() - calls = [ - mock.call( - ["docker", "compose", "exe", "backend", "bash"], - universal_newlines=True, - shell=False, - check=True, - ), - ] - run.assert_has_calls(calls) - @mock.patch("legl_dev.command.run") def test_remote_frontend_commands(run): - main.remote("frontend") + main.shell("frontend") calls = [ mock.call( - ["docker", "compose", "exe", "frontend", "bash"], + ["docker", "compose", "exec", "frontend", "bash"], universal_newlines=True, shell=False, check=True, @@ -189,10 +175,10 @@ def test_remote_frontend_commands(run): @mock.patch("legl_dev.command.run") def test_remote_frontend_commands(run): - main.remote("frontend") + main.shell("frontend") calls = [ mock.call( - ["docker", "compose", "exe", "frontend", "bash"], + ["docker", "compose", "exec", "frontend", "bash"], universal_newlines=True, shell=False, check=True,