#236 Show proper error message when unknown Koji tag is used as ODCS input.
Merged 5 months ago by jkaluza. Opened 5 months ago by jkaluza.
jkaluza/odcs missing-koji-tag  into  master

@@ -252,6 +252,8 @@ 

      """

  

      info = koji_session.getTag(tag)

+     if not info:

+         raise ValueError("Unknown Koji tag %s." % tag)

      ids = [info["id"]]

      seen_tags = tags or set()

      inheritance_data = koji_session.getInheritanceData(tag)

file modified
+9 -1

@@ -33,7 +33,8 @@ 

  from odcs.server.pungi import PungiSourceType

  from odcs.server.backend import (resolve_compose, get_reusable_compose,

                                   generate_compose, generate_pulp_compose,

-                                  generate_pungi_compose, validate_pungi_compose)

+                                  generate_pungi_compose, validate_pungi_compose,

+                                  koji_get_inherited_tags)

  from odcs.server.utils import makedirs

  import odcs.server.backend

  from .utils import ModelsBaseTest

@@ -223,6 +224,13 @@ 

          reused_c = get_reusable_compose(c)

          self.assertEqual(reused_c, old_c)

  

+     def test_koji_get_inherited_tags_unknown_tag(self):

+         koji_session = MagicMock()

+         koji_session.getTag.return_value = None

+ 

+         with self.assertRaisesRegexp(ValueError, 'Unknown Koji tag foo.'):

+             koji_get_inherited_tags(koji_session, "foo")

+ 

      @patch("odcs.server.backend.koji_get_inherited_tags")

      @patch("odcs.server.backend.create_koji_session")

      def test_get_reusable_tag_compose(