From 7fc99becfb239da88860936181db939b64b3eedf Mon Sep 17 00:00:00 2001 From: Jusuf Date: Fri, 22 Nov 2024 13:15:19 +0100 Subject: [PATCH 1/2] Add tests for agent register/unregister - Add test for agent registration in Astarte pairing service - Add test for agent unregistration in Astarte pairing service Signed-off-by: Jusuf --- tests/pairing_agent/test_pairing_agent.py | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/pairing_agent/test_pairing_agent.py diff --git a/tests/pairing_agent/test_pairing_agent.py b/tests/pairing_agent/test_pairing_agent.py new file mode 100644 index 0000000..ef6c532 --- /dev/null +++ b/tests/pairing_agent/test_pairing_agent.py @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: 2024 SECO Mind Srl +# +# SPDX-License-Identifier: Apache-2.0 + + +import subprocess + + +def test_pairing_agent_register(astarte_env_vars): + astarte_url = astarte_env_vars["astarte_url"] + realm = astarte_env_vars["realm"] + jwt = astarte_env_vars["jwt"] + device_test_2 = astarte_env_vars["device_test_2"] + + arg_list = [ + "astartectl", + "pairing", + "agent", + "register", + device_test_2, + "-t", + jwt, + "-u", + astarte_url, + "-r", + realm, + ] + sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) + assert "successfully registered" in sample_data_result.stdout + + +def test_pairing_agent_unregister(astarte_env_vars): + astarte_url = astarte_env_vars["astarte_url"] + realm = astarte_env_vars["realm"] + jwt = astarte_env_vars["jwt"] + device_test_2 = astarte_env_vars["device_test_2"] + + arg_list = [ + "astartectl", + "pairing", + "agent", + "unregister", + device_test_2, + "-t", + jwt, + "-u", + astarte_url, + "-r", + realm, + ] + sample_data_result = subprocess.run(arg_list, capture_output=True, text=True, input="y\n") + assert "ok" in sample_data_result.stdout From 4f69d60a2078435776d78676687fd88e0dc77f8a Mon Sep 17 00:00:00 2001 From: Jusuf Date: Fri, 22 Nov 2024 13:28:28 +0100 Subject: [PATCH 2/2] Add package configuration to pyproject.toml - Include pairing_agent in the project packages Signed-off-by: Jusuf --- test.sh | 1 + tests/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 601d472..b550882 100755 --- a/test.sh +++ b/test.sh @@ -7,3 +7,4 @@ pytest -v ./tests/utils pytest -v ./tests/app_engine pytest -v ./tests/realm_management +pytest -v ./tests/pairing_agent diff --git a/tests/pyproject.toml b/tests/pyproject.toml index 888a834..edbb1ea 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -33,4 +33,4 @@ profile = "black" line-length = 88 [tool.setuptools] -packages = ["app_engine", "realm_management", "utils"] +packages = ["app_engine", "realm_management", "utils", "pairing_agent"]