#1633 Fix lookup_name usage + tests
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1632  into  master

file modified
+2 -2
@@ -6637,8 +6637,8 @@ 

      btype = lookup_name('btype', type, strict=False)

      if btype is None:

          raise koji.BuildError('unsupported build type: %s' % type)

-     if btype not in get_build_type(buildinfo, strict=True):

-         raise koji.ImportError('Build does not have type %s', btype)

+     if btype['name'] not in get_build_type(buildinfo, strict=True):

+         raise koji.ImportError('Build does not have type %s' % btype['name'])

      archiveinfo['btype_id'] = btype['id']

  

      # cg extra data

@@ -131,7 +131,7 @@ 

          if table == 'btype':

              return {

                      'id': 'BTYPEID:%s' % info,

-                     'name': 'BTYPE:%s' % info,

+                     'name': info,

                      }

          else:

              raise Exception("Cannot fake call")
@@ -189,6 +189,7 @@ 

                  'source': None,

                  'state': koji.BUILD_STATES['BUILDING'],

                  'volume_id': 0,

+                 'extra': {},

                  }

          image_info = {'build_id': buildinfo['id']}

          self.get_build.return_value = buildinfo

@@ -73,7 +73,7 @@ 

  

      def my_lookup_name(self, table, info, **kw):

          if table == 'btype':

-             return mock.MagicMock()

+             return {'name': 'maven', 'id': 1234}

          else:

              raise Exception("Cannot fake call")

  
@@ -121,6 +121,7 @@ 

          buildinfo['state'] = koji.BUILD_STATES['BUILDING']

          buildinfo['volume_id'] = 0

          buildinfo['volume_name'] = 'DEFAULT'

+         buildinfo['extra'] = {}

          maven_info = self.maven_data['maven_info'].copy()

          maven_info['build_id'] = buildinfo['id']

          self.get_build.return_value = buildinfo