From 057b2a0ee0e2d506434209220df30e247199397c Mon Sep 17 00:00:00 2001 From: Roger Date: Sat, 17 Feb 2024 20:50:49 +0100 Subject: [PATCH] fix: github actions: python tests --- .github/workflows/python-tests.yml | 1 - tests/container/test_container.py | 10 +++++----- tests/util/test_accessor.py | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 2da9247..2bfa54d 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -55,7 +55,6 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Run Tests - working-directory: ./ run: | python -m unittest tests/*/test_*.py diff --git a/tests/container/test_container.py b/tests/container/test_container.py index 96eb9a9..b3405ae 100644 --- a/tests/container/test_container.py +++ b/tests/container/test_container.py @@ -18,7 +18,7 @@ def test_container_not_valid(self): container = Container("Foo") self.assertFalse(container.exists(), "Container not exist! Expected: 'False'") - @patch("subprocess.check_output", return_value=open("fixtures/docker_inspect_volume_only.output").read()) + @patch("subprocess.check_output", return_value=open("tests/fixtures/docker_inspect_volume_only.output").read()) def test_determine_volumes(self, mock_check_output): container = Container("Foo") container.determine_volume() @@ -27,7 +27,7 @@ def test_determine_volumes(self, mock_check_output): self.assertFalse(container.has_docker_bindings, "Unexpected container bindings found!") self.assertEqual(container.docker_bindings, [], "Unexpected container bindings found!") - @patch("subprocess.check_output", return_value=open("fixtures/docker_inspect_multiple_volumes.output").read()) + @patch("subprocess.check_output", return_value=open("tests/fixtures/docker_inspect_multiple_volumes.output").read()) def test_determine_multiple_volumes(self, mock_check_output): container = Container("Foo") container.determine_volume() @@ -38,7 +38,7 @@ def test_determine_multiple_volumes(self, mock_check_output): self.assertEqual(container.docker_bindings, ["/opt/foo/bar", "/var/log"], "Binding destinations not correct!") - @patch("subprocess.check_output", return_value=open("fixtures/docker_inspect_invalid_output.output").read()) + @patch("subprocess.check_output", return_value=open("tests/fixtures/docker_inspect_invalid_output.output").read()) def test_determine_invalid_output(self, mock_check_output): container = Container("Foo") with self.assertRaises(json.JSONDecodeError) as err: @@ -60,7 +60,7 @@ def test_is_container_started_by_compose(self, mock_inspect_container): container = Container("foo") # Mocking the return value - with open("fixtures/docker_inspect_with_compose.json") as file: + with open("tests/fixtures/docker_inspect_with_compose.json") as file: mock_inspect_container.return_value = json.load(file) self.assertEqual((True, "/docker/foo/docker-compose.yml"), container._is_container_started_by_compose()) @@ -70,7 +70,7 @@ def test_is_container_started_by_compose_false(self, mock_inspect_container): container = Container("foo") # Mocking the return value - with open("fixtures/docker_inspect_without_compose.json") as file: + with open("tests/fixtures/docker_inspect_without_compose.json") as file: mock_inspect_container.return_value = json.load(file) self.assertEqual((False, None), container._is_container_started_by_compose()) diff --git a/tests/util/test_accessor.py b/tests/util/test_accessor.py index a8eb232..cc04edc 100644 --- a/tests/util/test_accessor.py +++ b/tests/util/test_accessor.py @@ -53,11 +53,11 @@ def tearDown(self): pass def test_validate_env_settings(self): - load_dotenv("fixtures/env_files/.env_ok") + load_dotenv("tests/fixtures/env_files/.env_ok") self.assertIsNone(EnvSettings().validate(), "Validate correct env settings failed") def test_validate_env_settings_chat_error(self): - load_dotenv("fixtures/env_files/.env_chat_error") + load_dotenv("tests/fixtures/env_files/.env_chat_error") with self.assertRaises(ValueError) as err: EnvSettings().validate() @@ -65,7 +65,7 @@ def test_validate_env_settings_chat_error(self): "Chat settings error not raised") def test_validate_env_settings_slack_error(self): - load_dotenv("fixtures/env_files/.env_chat_slack_error") + load_dotenv("tests/fixtures/env_files/.env_chat_slack_error") with self.assertRaises(ValueError) as err: EnvSettings().validate() @@ -73,7 +73,7 @@ def test_validate_env_settings_slack_error(self): str(err.exception), "Slack settings error not raised") def test_validate_env_settings_mqtt_error(self): - load_dotenv("fixtures/env_files/.env_mqtt_error") + load_dotenv("tests/fixtures/env_files/.env_mqtt_error") with self.assertRaises(ValueError) as err: EnvSettings().validate()