From f5ce303053c5560455572e39e1dbe6e5e7bf4c15 Mon Sep 17 00:00:00 2001 From: Michael Hwang Date: Thu, 7 Sep 2017 16:00:09 -0400 Subject: Add in functionality for policy notification Change-Id: I4ef4bc9c35266814f226cbad13c55d11901c8e79 Issue-Id: DCAEGEN2-97 Signed-off-by: Michael Hwang --- python-dockering/tests/test_core.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'python-dockering/tests/test_core.py') diff --git a/python-dockering/tests/test_core.py b/python-dockering/tests/test_core.py index e99dbd4..f66f88c 100644 --- a/python-dockering/tests/test_core.py +++ b/python-dockering/tests/test_core.py @@ -25,6 +25,7 @@ from dockering import core as doc from dockering.exceptions import DockerError, DockerConnectionError +@pytest.mark.skip(reason="Need to automatically setup Docker engine and maybe Consul") def test_create_client(): # Bad - Could not connect to docker engine @@ -33,8 +34,8 @@ def test_create_client(): # TODO: Does pytest provide an env file? -CONSUL_HOST = os.environ["CONSUL_HOST"] -EXTERNAL_IP = os.environ["EXTERNAL_IP"] +CONSUL_HOST = os.environ.get("CONSUL_HOST") +EXTERNAL_IP = os.environ.get("EXTERNAL_IP") @pytest.mark.skip(reason="Need to automatically setup Docker engine and maybe Consul") def test_create_container(): @@ -69,3 +70,19 @@ def test_create_container(): doc.stop_then_remove_container(client, scn) except: print("Container removal failed") + + +def test_build_policy_update_cmd(): + assert ["/bin/sh", "/bin/foo", "policy", "{}"] == doc.build_policy_update_cmd("/bin/foo") + assert ["/bin/foo", "policy", "{}"] == doc.build_policy_update_cmd("/bin/foo", use_sh=False) + + kwargs = { "bar": "baz" } + + assert ["/bin/foo", "policy", "{\"bar\": \"baz\"}"] == doc.build_policy_update_cmd( + "/bin/foo", use_sh=False, **kwargs) + + assert ["/bin/foo", "policy", "{\"application_config\": {\"key\": \"hello world\"}}"] \ + == doc.build_policy_update_cmd("/bin/foo", use_sh=False, + application_config={"key": "hello world"}) + + -- cgit 1.2.3-korg