diff --git a/tests/tests_manifests_workflow/test_input_manifests.py b/tests/tests_manifests_workflow/test_input_manifests.py index be5aad53fa..18c9a50abe 100644 --- a/tests/tests_manifests_workflow/test_input_manifests.py +++ b/tests/tests_manifests_workflow/test_input_manifests.py @@ -10,6 +10,7 @@ from unittest.mock import MagicMock, call, mock_open, patch from manifests.input_manifest import InputManifest +from manifests.test_manifest import TestManifest from manifests_workflow.input_manifests import InputManifests @@ -119,15 +120,24 @@ def test_create_manifest_opensearch_dashboards_previous_base_version(self) -> No input_manifest_compare = InputManifest.from_file(open(manifest_path)) self.assertEqual(input_manifest.to_dict(), input_manifest_compare.to_dict()) + @patch("manifests.manifest.Manifest.to_file") @patch("os.makedirs") @patch("manifests_workflow.input_manifests.InputManifests.create_manifest") - def test_write_manifest(self, mock_create_manifest: MagicMock, mock_makedirs: MagicMock) -> None: + def test_write_manifest(self, mock_create_manifest: MagicMock, mock_makedirs: MagicMock, mock_to_file: MagicMock) -> None: + input_manifest = InputManifest.from_file(open(os.path.join(os.path.dirname(__file__), "data", "opensearch-2.12.1000.yml"))) + test_manifest = TestManifest.from_file(open(os.path.join(os.path.dirname(__file__), "data", "opensearch-2.12.1000-test.yml"))) + mock_create_manifest.return_value = (input_manifest, test_manifest) input_manifests = InputManifests("opensearch") - input_manifests.write_manifest('0.1.2', '0.x', []) - mock_create_manifest.assert_called_with('0.1.2', '0.x', []) - mock_makedirs.assert_called_with(os.path.join(InputManifests.manifests_path(), '0.1.2'), exist_ok=True) - mock_create_manifest.return_value.to_file.assert_called_with( - os.path.join(InputManifests.manifests_path(), '0.1.2', 'opensearch-0.1.2.yml') + input_manifests.write_manifest('2.12.1000', '2.x', []) + mock_create_manifest.assert_called_with('2.12.1000', '2.x', []) + mock_makedirs.assert_called_with(os.path.join(InputManifests.manifests_path(), '2.12.1000'), exist_ok=True) + self.assertEqual( + mock_to_file.call_args_list[0][0][0], + os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "manifests", "2.12.1000", "opensearch-2.12.1000.yml")) + ) + self.assertEqual( + mock_to_file.call_args_list[1][0][0], + os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "manifests", "2.12.1000", "opensearch-2.12.1000-test.yml")) ) def test_jenkins_path(self) -> None: