#63 Let packagers_without_bugzilla ignore some namespaces
Merged 3 years ago by pingou. Opened 3 years ago by pingou.

@@ -53,6 +53,65 @@ 

      @patch("toddlers.utils.fedora_account.get_bz_email_group")

      @patch("toddlers.utils.fedora_account.get_bz_email_user")

      @patch("toml.load")

+     def test_process_ignorable_namespaces(

+         self,

+         toml_load,

+         get_bz_email_user,

+         get_bz_email_group,

+         bz_get_group_member,

+         bz_get_user,

+         send_email,

+         toddler,

+     ):

+         toml_load.return_value = {}

+         get_bz_email_user.side_effect = [

+             "besser82@fp.o",

+             "churchyard@fp.o",

+             "dwmw2@fp.o",

+         ]

+         get_bz_email_group.side_effect = ["python-sig@lists.fp.o"]

+         bz_get_group_member.return_value = ["dwmw2@fp.o", "besser82@fp.o"]

+         bz_get_user.side_effect = [Exception("ahah"), False, False, False]

+ 

+         req = Mock()

+         req.ok = True

+         req.json.return_value = {

+             "rpms": {

+                 "0xFFFF": ["dwmw2"],

+                 "2048-cli": ["besser82"],

+                 "CuraEngine": ["@python-sig", "churchyard"],

+             }

+         }

+         toddler.requests_session.get.return_value = req

+ 

+         toddler.process(

+             config={

+                 "email_overrides_file": "test",

+                 "bugzilla_group": "fedora_contrib",

+                 "dist_git_url": "https://src.fp.o",

+                 "admin_email": "admin@fp.o",

+                 "mail_server": "mail_server",

+                 "ignorable_namespaces": ["rpms"],

+             },

+             message=None,

+             username=False,

+         )

+ 

+         toml_load.assert_called_with("test")

+         get_bz_email_user.assert_not_called()

+         get_bz_email_group.assert_not_called()

+         bz_get_group_member.assert_called_with("fedora_contrib")

+         bz_get_user.assert_not_called()

+         send_email.assert_not_called()

+ 

+     @patch("toddlers.utils.fedora_account.set_fas", new=Mock(return_value=True))

+     @patch("toddlers.utils.bugzilla_system.set_bz", new=Mock(return_value=True))

+     @patch("toddlers.utils.notify.send_email")

+     @patch("toddlers.utils.bugzilla_system.get_user")

+     @patch("toddlers.utils.bugzilla_system.get_group_member")

+     @patch("toddlers.utils.fedora_account.get_bz_email_group")

+     @patch("toddlers.utils.fedora_account.get_bz_email_user")

+     @patch("toml.load")

      def test_process(

          self,

          toml_load,

file modified
+4
@@ -177,6 +177,10 @@ 

  [consumer_config.clean_retired_packages]

  pdc_active_branches = "https://pdc.fedoraproject.org/extras/active_branches.json"

  

+ [consumer_config.packagers_without_bugzilla]

+ ignorable_namespaces = ["tests"]

+ 

+ 

  

  [qos]

  prefetch_size = 0

@@ -64,7 +64,7 @@ 

              "toddlers.trigger.packagers_without_bugzilla"

          )

  

-     def get_user_and_groups_dist_git(self, dist_git_url):

+     def get_user_and_groups_dist_git(self, dist_git_url, ignorable_namespaces):

          """Returns a tuple of list containing in the first one all the users and

          in the second all the groups found in dist-git in the JSON file meant to be

          synced to bugzilla.
@@ -77,6 +77,9 @@ 

          users = set()

          groups = set()

          for namespace in data:

+             if namespace in ignorable_namespaces:

+                 continue

+ 

              for package in data[namespace]:

                  for name in data[namespace][package]:

                      if name.startswith("@"):
@@ -103,7 +106,8 @@ 

              # Retrieve all the packagers and groups in dist-git

              _log.info("Retrieving the list of packagers and group in dist-git")

              fas_packagers, fas_groups = self.get_user_and_groups_dist_git(

-                 config["dist_git_url"]

+                 config["dist_git_url"],

+                 config.get("ignorable_namespaces") or [],

              )

          else:

              if username.startswith("@"):

Pagure supports enforcing group membership on some namespaces
only. So for example on src.fp.o users must be in the packager
group to be added to projects on the rpms or the modules
namespaces. However, this requirement does not apply for project
in the "tests" namespace.
So when checking if packager have a valid bugzilla account, we can
(and should) ignore these namespaces.

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

Looks reasonable to me.

Build succeeded.

  • tox : SUCCESS in 6m 20s

rebased onto 2cc234d

3 years ago

Pull-Request has been merged by pingou

3 years ago

Build succeeded.

  • tox : SUCCESS in 6m 08s