This repository has been archived on 2023-11-29. You can view files and clone it, but cannot push or open issues or pull requests.
WebPicDownloader/tests/test_update_regex.py

49 lines
1.5 KiB
Python
Raw Permalink Normal View History

import unittest
from re import fullmatch, compile, Pattern
class TestUpdateRegex(unittest.TestCase):
"""
Test Class for Update Regex
Versions can vary between 0.0.0 and 99.99.99 and cannot exceed two units.
0.0.0 to 0.99.99 = BETA
1.0.0 to 99.99.99 = RELEASE
"""
regex: Pattern = compile(r'^(\d{1,2}\.)(\d{1,2}\.)(\d{1,2})$')
def test_first_version(self):
self.assertTrue(fullmatch(self.regex, '1.0.0'))
def test_patch_version(self):
self.assertTrue(fullmatch(self.regex, '1.0.00'))
self.assertTrue(fullmatch(self.regex, '1.0.1'))
self.assertTrue(fullmatch(self.regex, '1.0.12'))
self.assertTrue(fullmatch(self.regex, '1.0.54'))
def test_minor_version(self):
self.assertTrue(fullmatch(self.regex, '1.00.0'))
self.assertTrue(fullmatch(self.regex, '1.1.0'))
self.assertTrue(fullmatch(self.regex, '1.98.0'))
self.assertTrue(fullmatch(self.regex, '1.24.0'))
def test_major_version(self):
self.assertTrue(fullmatch(self.regex, '00.0.0'))
self.assertTrue(fullmatch(self.regex, '10.0.0'))
self.assertTrue(fullmatch(self.regex, '99.0.0'))
self.assertTrue(fullmatch(self.regex, '42.0.0'))
def test_bad_version(self):
self.assertFalse(fullmatch(self.regex, '1.0.0000'))
self.assertFalse(fullmatch(self.regex, '1.00000.0'))
self.assertFalse(fullmatch(self.regex, '100.0.0'))
self.assertFalse(fullmatch(self.regex, '152.124.15'))
if __name__ == '__main__':
unittest.main()