diff --git a/.github/workflows/push_event_workflow.yml b/.github/workflows/push_event_workflow.yml index 2bec316..61c9fbc 100644 --- a/.github/workflows/push_event_workflow.yml +++ b/.github/workflows/push_event_workflow.yml @@ -17,4 +17,6 @@ jobs: - name : Run tests working-directory: ./installation_and_upgrade - run : python -m unittest discover \ No newline at end of file + run: | + pip install pytest pytest-cov + python -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html \ No newline at end of file diff --git a/installation_and_upgrade/ibex_install_utils/tests/test_version_check.py b/installation_and_upgrade/ibex_install_utils/tests/test_version_check.py index 4917be9..4887ba1 100644 --- a/installation_and_upgrade/ibex_install_utils/tests/test_version_check.py +++ b/installation_and_upgrade/ibex_install_utils/tests/test_version_check.py @@ -1,24 +1,24 @@ -import unittest +import pytest from ibex_install_utils.version_check import * -class TestVersionCheck(unittest.TestCase): +class TestVersionCheck: def test_get_major_minor_patch(self): # good version patterns - self.assertEqual(get_major_minor_patch("17"), "17.0.0") - self.assertEqual(get_major_minor_patch("17.0"), "17.0.0") - self.assertEqual(get_major_minor_patch("17.23"), "17.23.0") - self.assertEqual(get_major_minor_patch("17.0.7.3"), "17.0.7") - self.assertEqual(get_major_minor_patch("17.0.0.3"), "17.0.0") + assert get_major_minor_patch("17") == "17.0.0" + assert get_major_minor_patch("17.0") == "17.0.0" + assert get_major_minor_patch("17.23") == "17.23.0" + assert get_major_minor_patch("17.0.7.3") == "17.0.7" + assert get_major_minor_patch("17.0.0.3") == "17.0.0" # wrong version patterns - with self.assertRaises(AttributeError): + with pytest.raises(AttributeError): get_major_minor_patch("17.0.0.3.4") - with self.assertRaises(AttributeError): + with pytest.raises(AttributeError): get_major_minor_patch("17.") - with self.assertRaises(AttributeError): + with pytest.raises(AttributeError): get_major_minor_patch("java 17.2.4") # def test_get_file_version(self): @@ -29,6 +29,3 @@ def test_get_major_minor_patch(self): # example_file = "\\\\isis.cclrc.ac.uk\shares\ISIS_Experiment_Controls_Public\\third_party_installers\latest_versions\OpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi" # version = get_msi_property(example_file, MSI_PRODUCT_VERSION_PROPERTY) # self.assertEqual(version, "17.0.4.101") - -if __name__ == '__main__': - unittest.main() \ No newline at end of file diff --git a/installation_and_upgrade/requirements.txt b/installation_and_upgrade/requirements.txt index e39e45e..4cc59e3 100644 --- a/installation_and_upgrade/requirements.txt +++ b/installation_and_upgrade/requirements.txt @@ -3,6 +3,7 @@ GitPython==3.1.41 kafka_python==2.0.2 lxml==4.9.3 psutil==5.9.5 +pytest==8.0.0 pywin32==306 semantic_version==2.10.0 six==1.16.0