Repository: fedora-infra/bodhi

Issue:
Add code for Bodhi to be able to identify containers in Koji
There's a little [code that determines what kind of Build a Koji build is](https://github.com/fedora-infra/bodhi/blob/b786fbdbcbdb82db0b2b481b7201c30c81c592a0/bodhi/server/models.py#L364-L366). We should make that code work with the new Enum instead of raising ```NotImplemented()```.

Depends on #2026.


Discussion:

Resolving patch:
diff --git a/bodhi/server/buildsys.py b/bodhi/server/buildsys.py
--- a/bodhi/server/buildsys.py
+++ b/bodhi/server/buildsys.py
@@ -350,6 +350,15 @@ def listTags(self, build, *args, **kw):
                 {'arches': 'x86_64', 'id': 17, 'locked': True,
                  'name': 'f27M'},
             ]
+        elif 'container' in build:
+            result = [
+                {'arches': 'x86_64', 'id': 15, 'locked': True,
+                 'name': 'f28C-updates-candidate'},
+                {'arches': 'x86_64', 'id': 16, 'locked': True,
+                 'name': 'f28C-updates-testing'},
+                {'arches': 'x86_64', 'id': 17, 'locked': True,
+                 'name': 'f28C'},
+            ]
         else:
             release = build.split('.')[-1].replace('fc', 'f')
             result = [
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -556,8 +556,7 @@ def infer_content_class(cls, base, build):
         if 'module' in extra.get('typeinfo', {}):
             identity = cls.module
         elif 'container_koji_task_id' in extra:
-            # TODO - implement containers as yet another content type someday.
-            raise NotImplementedError("Inferred type 'container' is unhandled.")
+            identity = cls.container
 
         return base.find_polymorphic_child(identity)
 


Test patch:
diff --git a/bodhi/tests/server/services/test_updates.py b/bodhi/tests/server/services/test_updates.py
--- a/bodhi/tests/server/services/test_updates.py
+++ b/bodhi/tests/server/services/test_updates.py
@@ -308,13 +308,33 @@ def test_new_module_update(self, publish, *args):
     @mock.patch(**mock_valid_requirements)
     @mock.patch('bodhi.server.notifications.publish')
     def test_new_container_update(self, publish, *args):
-        data = self.get_update('mariadb-10.1-10.f25container')
-        r = self.app.post_json('/updates/', data, status=501)
+        self.create_release(u'28C')
+        data = self.get_update('mariadb-10.1-10.f28container')
+
+        r = self.app.post_json('/updates/', data, status=200)
+
         up = r.json_body
-        self.assertEquals(up['status'], 'error')
-        self.assertEquals(up['errors'][1]['description'],
-                          'Unable to infer content_type.  '
-                          '"Inferred type \'container\' is unhandled."')
+        self.assertEquals(up['title'], u'mariadb-10.1-10.f28container')
+        self.assertEquals(up['status'], u'pending')
+        self.assertEquals(up['request'], u'testing')
+        self.assertEquals(up['user']['name'], u'guest')
+        self.assertEquals(up['release']['name'], u'F28C')
+        self.assertEquals(up['type'], u'bugfix')
+        self.assertEquals(up['content_type'], u'container')
+        self.assertEquals(up['severity'], u'unspecified')
+        self.assertEquals(up['suggest'], u'unspecified')
+        self.assertEquals(up['close_bugs'], True)
+        self.assertEquals(up['notes'], u'this is a test update')
+        self.assertIsNotNone(up['date_submitted'])
+        self.assertEquals(up['date_modified'], None)
+        self.assertEquals(up['date_approved'], None)
+        self.assertEquals(up['date_pushed'], None)
+        self.assertEquals(up['locked'], False)
+        self.assertEquals(up['alias'], u'FEDORA-%s-033713b73b' % YEAR)
+        self.assertEquals(up['karma'], 0)
+        self.assertEquals(up['requirements'], 'rpmlint')
+        publish.assert_called_once_with(
+            topic='update.request.testing', msg=mock.ANY)
 
     @mock.patch.dict('bodhi.server.validators.config', {'acl_system': u'dummy'})
     @mock.patch(**mock_valid_requirements)