Bug 1453274 - Add testing for python/mozrelease/versions.py r=rail
authorJustin Wood <Callek@gmail.com>
Mon, 23 Apr 2018 12:40:26 -0400
changeset 468614 0b24ec75e7531c08d7cb33c3cf0c07788c08500f
parent 468613 c9c139814504908e4d4e032ed0665de1be27f9f4
child 468615 f12de32d3468fd00d541c2a8557cb0a33ebf398d
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrail
bugs1453274
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453274 - Add testing for python/mozrelease/versions.py r=rail for: taskgraph: Make update tasks support esr60 MozReview-Commit-ID: GUmAq3sBXGB
build/virtualenv_packages.txt
python/moz.build
python/mozrelease/test/python.ini
python/mozrelease/test/test_versions.py
--- a/build/virtualenv_packages.txt
+++ b/build/virtualenv_packages.txt
@@ -1,12 +1,13 @@
 mozilla.pth:python/mach
 mozilla.pth:python/mozboot
 mozilla.pth:python/mozbuild
 mozilla.pth:python/mozlint
+mozilla.pth:python/mozrelease
 mozilla.pth:python/mozterm
 mozilla.pth:python/mozversioncontrol
 mozilla.pth:python/l10n
 mozilla.pth:third_party/python/blessings
 mozilla.pth:third_party/python/compare-locales
 mozilla.pth:third_party/python/configobj
 mozilla.pth:third_party/python/cram
 mozilla.pth:third_party/python/dlmanager
--- a/python/moz.build
+++ b/python/moz.build
@@ -52,16 +52,17 @@ SPHINX_TREES['python'] = 'docs'
 
 with Files('mach/docs/**'):
     SCHEDULES.exclusive = ['docs']
 
 PYTHON_UNITTEST_MANIFESTS += [
     'mach/mach/test/python.ini',
     'mozbuild/dumbmake/test/python.ini',
     'mozlint/test/python.ini',
+    'mozrelease/test/python.ini',
     'mozterm/test/python.ini',
     'mozversioncontrol/test/python.ini',
 ]
 
 if CONFIG['MOZ_BUILD_APP']:
     PYTHON_UNITTEST_MANIFESTS += [
         'mozbuild/mozbuild/test/python.ini',
         'mozbuild/mozpack/test/python.ini',
new file mode 100644
--- /dev/null
+++ b/python/mozrelease/test/python.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+subsuite=mozrelease
+
+[test_versions.py]
new file mode 100644
--- /dev/null
+++ b/python/mozrelease/test/test_versions.py
@@ -0,0 +1,98 @@
+from __future__ import absolute_import
+
+import mozunit
+import pytest
+
+from mozrelease.versions import MozillaVersion
+
+
+ALL_VERSIONS = [  # Keep this sorted
+    '3.0',
+    '3.0.1',
+    '3.0.2',
+    '3.0.3',
+    '3.0.4',
+    '3.0.5',
+    '3.0.6',
+    '3.0.7',
+    '3.0.8',
+    '3.0.9',
+    '3.0.10',
+    '3.0.11',
+    '3.0.12',
+    '3.0.13',
+    '3.0.14',
+    '3.0.15',
+    '3.0.16',
+    '3.0.17',
+    '3.0.18',
+    '3.0.19',
+    '3.1b1',
+    '3.1b2',
+    '3.1b3',
+    '3.5b4',
+    '3.5b99',
+    '3.5rc1',
+    '3.5rc2',
+    '3.5rc3',
+    '3.5',
+    '3.5.1',
+    '3.5.2',
+    '3.5.3',
+    '3.5.4',
+    '3.5.5',
+    '3.5.6',
+    '3.5.7',
+    '3.5.8',
+    '3.5.9',
+    '3.5.10',
+    # ... Start skipping around...
+    '4.0b9',
+    # '10.0.2esr',
+    # '10.0.3esr',
+    '32.0',
+    '49.0a1',
+    '49.0a2',
+    '59.0',
+    '60.0',
+    # '60.0esr',
+    # '60.0.1esr',
+    '60.1',
+    # '60.1.0esr',
+    '61.0',
+]
+
+
+@pytest.fixture(scope='function',
+                params=range(len(ALL_VERSIONS) - 1),
+                ids=lambda x: "{}, {}".format(ALL_VERSIONS[x], ALL_VERSIONS[x+1]))
+def comparable_versions(request):
+    index = request.param
+    return ALL_VERSIONS[index], ALL_VERSIONS[index + 1]
+
+
+@pytest.mark.parametrize('version', ALL_VERSIONS)
+def test_versions_parseable(version):
+    """Test that we can parse previously shipped versions.
+
+    We only test 3.0 and up, since we never generate updates against
+    versions that old."""
+    assert MozillaVersion(version) is not None
+
+
+def test_versions_compare(comparable_versions):
+    """Test that versions properly compare in order."""
+    smaller_version, larger_version = comparable_versions
+    assert MozillaVersion(smaller_version) < MozillaVersion(larger_version)
+    assert MozillaVersion(larger_version) > MozillaVersion(smaller_version)
+    assert MozillaVersion(larger_version) != MozillaVersion(smaller_version)
+
+
+@pytest.mark.parametrize('version', ALL_VERSIONS)
+def test_versions_compare_equal(version):
+    """Test that versions properly compare as equal through multiple passes."""
+    assert MozillaVersion(version) == MozillaVersion(version)
+
+
+if __name__ == '__main__':
+    mozunit.main()