Bug 1652638 - Unittests for comm_taskgraph.parameters. r=justdave
authorRob Lemley <rob@thunderbird.net>
Fri, 21 May 2021 00:38:07 +0000
changeset 32671 9c597bc8c9f2bfa6dbbcb12ca92136ae9c1c091f
parent 32670 fb67ae9e355ee74f1fd18700d72c772a3d229d4f
child 32672 b18ab1902490793309150c478d214763e8fa59fc
push id18828
push userthunderbird@calypsoblue.org
push dateThu, 27 May 2021 21:37:24 +0000
treeherdercomm-central@568b56686fdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjustdave
bugs1652638
Bug 1652638 - Unittests for comm_taskgraph.parameters. r=justdave Differential Revision: https://phabricator.services.mozilla.com/D83860
build/virtualenv_packages.txt
mail/moz.build
taskcluster/comm_taskgraph/test/__init__.py
taskcluster/comm_taskgraph/test/python.ini
taskcluster/comm_taskgraph/test/test_parameters.py
taskcluster/moz.build
--- a/build/virtualenv_packages.txt
+++ b/build/virtualenv_packages.txt
@@ -1,3 +1,4 @@
 comm.pth:comm/testing/marionette
 comm.pth:comm/python/l10n
+comm.pth:comm/taskcluster
 comm.pth:comm/python/thirdroc
--- a/mail/moz.build
+++ b/mail/moz.build
@@ -16,17 +16,20 @@ DIRS += [
 ]
 
 if CONFIG["MAKENSISU"]:
     DIRS += ["installer/windows"]
 
 if CONFIG["MOZ_BUNDLED_FONTS"]:
     DIRS += ["/%s/browser/fonts" % CONFIG["mozreltopsrcdir"]]
 
-DIRS += ["../third_party"]
+DIRS += [
+    "../taskcluster",
+    "../third_party",
+]
 
 TEST_DIRS += [
     "test/browser",
     "test/marionette",
     "test/static",
 ]
 
 FINAL_TARGET_FILES.defaults += ["app/permissions"]
new file mode 100644
--- /dev/null
+++ b/taskcluster/comm_taskgraph/test/__init__.py
@@ -0,0 +1,5 @@
+#  This Source Code Form is subject to the terms of the Mozilla Public
+#  License, v. 2.0. If a copy of the MPL was not distributed with this
+#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
new file mode 100644
--- /dev/null
+++ b/taskcluster/comm_taskgraph/test/python.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+subsuite = comm_taskgraph
+
+[test_parameters.py]
new file mode 100644
--- /dev/null
+++ b/taskcluster/comm_taskgraph/test/test_parameters.py
@@ -0,0 +1,91 @@
+#  This Source Code Form is subject to the terms of the Mozilla Public
+#  License, v. 2.0. If a copy of the MPL was not distributed with this
+#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import unittest
+
+import comm_taskgraph.parameters  # noqa: F401
+from taskgraph.parameters import Parameters
+from mozunit import main
+
+
+class TestCommParameters(unittest.TestCase):
+
+    vals = {
+        "app_version": "app_version",
+        "backstop": False,
+        "base_repository": "base_repository",
+        "build_date": 0,
+        "build_number": 0,
+        "comm_base_repository": "comm_base_repository",
+        "comm_head_ref": "comm_head_ref",
+        "comm_head_repository": "comm_head_repository",
+        "comm_head_rev": "comm_head_rev",
+        "do_not_optimize": [],
+        "existing_tasks": {},
+        "filters": [],
+        "head_ref": "head_ref",
+        "head_repository": "head_repository",
+        "head_rev": "head_rev",
+        "hg_branch": "hg_branch",
+        "level": "level",
+        "message": "message",
+        "moz_build_date": "moz_build_date",
+        "next_version": "next_version",
+        "optimize_strategies": None,
+        "optimize_target_tasks": False,
+        "owner": "owner",
+        "phabricator_diff": "phabricator_diff",
+        "project": "project",
+        "pushdate": 0,
+        "pushlog_id": "pushlog_id",
+        "release_enable_emefree": False,
+        "release_enable_partner_repack": False,
+        "release_enable_partner_attribution": False,
+        "release_eta": None,
+        "release_history": {},
+        "release_partners": [],
+        "release_partner_config": None,
+        "release_partner_build_number": 1,
+        "release_type": "release_type",
+        "release_product": None,
+        "required_signoffs": [],
+        "signoff_urls": {},
+        "target_tasks_method": "target_tasks_method",
+        "test_manifest_loader": "default",
+        "tasks_for": "tasks_for",
+        "try_mode": "try_mode",
+        "try_options": None,
+        "try_task_config": {},
+        "version": "version",
+    }
+
+    def test_Parameters_check(self):
+        """
+        Specifying all of the gecko and comm parameters doesn't result in an error.
+        """
+        p = Parameters(**self.vals)
+        p.check()  # should not raise
+
+    def test_Parameters_check_missing(self):
+        """
+        If any of the comm parameters are specified, all of them must be specified.
+        """
+        vals = self.vals.copy()
+        del vals["comm_base_repository"]
+        p = Parameters(**vals)
+        self.assertRaises(Exception, p.check)
+
+    def test_Parameters_check_extra(self):
+        """
+        If parameters other than the global and comm parameters are specified,
+        an error is reported.
+        """
+        p = Parameters(extra="data", **self.vals)
+        self.assertRaises(Exception, p.check)
+
+
+if __name__ == "__main__":
+    main()
new file mode 100644
--- /dev/null
+++ b/taskcluster/moz.build
@@ -0,0 +1,16 @@
+#  This Source Code Form is subject to the terms of the Mozilla Public
+#  License, v. 2.0. If a copy of the MPL was not distributed with this
+#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+with Files("**"):
+    BUG_COMPONENT = ("Thunderbird", "Build Config")
+
+PYTHON_UNITTEST_MANIFESTS += [
+    "comm_taskgraph/test/python.ini",
+]