jenkins-bot has submitted this change and it was merged. Change subject: make-release: unit tests for MwVersion ......................................................................
make-release: unit tests for MwVersion Basic unit tests for the make-release MwVersion class using python unittest. Will let us refactor MwVersion to change 'branch' to 'tags' and populate the real branch name (aka: REL#_## or master). $ python -m unittest discover --verbose test_incomplete_version (tests.test_mwversion.TestMwVersion) ... ok test_major_version (tests.test_mwversion.TestMwVersion) ... ok test_master (tests.test_mwversion.TestMwVersion) ... ok test_minor_version (tests.test_mwversion.TestMwVersion) ... ok test_release_candidate (tests.test_mwversion.TestMwVersion) ... ok test_release_candidate_bumps (tests.test_mwversion.TestMwVersion) ... ok ---------------------------------------------------------------------- Ran 6 tests in 0.002s OK $ The runtest.sh is a helper to let people easily run the tests without having to figure out the exact command. bug: 57088 Change-Id: I25f5a9d28e4e1c0bb73ba3603f741d8be2c05f0b --- A make-release/runtests.sh A make-release/tests/__init__.py A make-release/tests/test_mwversion.py 3 files changed, 87 insertions(+), 0 deletions(-) Approvals: Hashar: Looks good to me, approved jenkins-bot: Verified diff --git a/make-release/runtests.sh b/make-release/runtests.sh new file mode 100755 index 0000000..1580cac --- /dev/null +++ b/make-release/runtests.sh @@ -0,0 +1 @@ +python -m unittest discover --verbose diff --git a/make-release/tests/__init__.py b/make-release/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/make-release/tests/__init__.py diff --git a/make-release/tests/test_mwversion.py b/make-release/tests/test_mwversion.py new file mode 100644 index 0000000..7e61536 --- /dev/null +++ b/make-release/tests/test_mwversion.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# +# Copyright 2013, Antoine "hashar" Musso +# Copyright 2013, Wikimedia Foundation Inc. + + +import unittest +makerelease = __import__('make-release') + + +class FakeVersion(makerelease.MwVersion): + + def __init__(self, attributes): + self.raw = None + self.major = None + self.branch = None + self.prev_version = None + self.prev_branch = None + + self.__dict__.update(attributes) + + +class TestMwVersion(unittest.TestCase): + + # Helper + def assertMwVersionEqual(self, expected, observed): + """Compare two object properties""" + return self.assertDictEqual(expected.__dict__, observed.__dict__) + + def test_master(self): + observed = makerelease.MwVersion('master') + expected = FakeVersion({'raw': 'master'}) + self.assertMwVersionEqual(expected, observed) + + def test_major_version(self): + observed = makerelease.MwVersion('1.22.0') + expected = FakeVersion({ + 'raw': '1.22.0', + 'major': '1.22', + 'branch': 'tags/1.22.0', + }) + self.assertMwVersionEqual(expected, observed) + + def test_minor_version(self): + observed = makerelease.MwVersion('1.22.1') + expected = FakeVersion({ + 'raw': '1.22.1', + 'major': '1.22', + 'branch': 'tags/1.22.1', + 'prev_branch': 'tags/1.22.0', + 'prev_version': '1.22.0', + }) + self.assertMwVersionEqual(expected, observed) + + def test_release_candidate(self): + observed = makerelease.MwVersion('1.22.0rc0') + expected = FakeVersion({ + 'raw': '1.22.0rc0', + 'major': '1.22', + 'branch': 'tags/1.22.0rc0', + }) + self.assertMwVersionEqual(expected, observed) + + def test_release_candidate_bumps(self): + observed = makerelease.MwVersion('1.22.0rc0') + expected = FakeVersion({ + 'raw': '1.22.0rc0', + 'major': '1.22', + 'branch': 'tags/1.22.0rc0', + }) + self.assertMwVersionEqual(expected, observed) + + observed = makerelease.MwVersion('1.22.0rc1') + expected = FakeVersion({ + 'raw': '1.22.0rc1', + 'major': '1.22', + 'branch': 'tags/1.22.0rc1', + 'prev_branch': 'tags/1.22.0rc0', + 'prev_version': '1.22.0rc0', + }) + self.assertMwVersionEqual(expected, observed) + + def test_incomplete_version(self): + observed = makerelease.MwVersion('1.22') + expected = FakeVersion({'raw': '1.22'}) + self.assertMwVersionEqual(expected, observed) -- To view, visit https://gerrit.wikimedia.org/r/96016 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I25f5a9d28e4e1c0bb73ba3603f741d8be2c05f0b Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/tools/release Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: CSteipp <cste...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: MarkAHershberger <mhershber...@wikimedia.org> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits