Skip to content

Commit

Permalink
Use pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoltkebel committed Feb 10, 2024
1 parent 380d2b9 commit b48499b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/push_event_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ jobs:
- name : Run tests
working-directory: ./installation_and_upgrade
run : python -m unittest discover
run: |
pip install pytest pytest-cov
python -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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()
1 change: 1 addition & 0 deletions installation_and_upgrade/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b48499b

Please sign in to comment.