Exemplo n.º 1
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.pathinfo = koji.PathInfo(self.tempdir)
     mock.patch('koji.pathinfo', new=self.pathinfo).start()
     self.hostcalls = kojihub.HostExports()
     self.context = mock.patch('kojihub.context').start()
     self.context.opts = {'EnableMaven': True}
     mock.patch('kojihub.Host').start()
     self.Task = mock.patch('kojihub.Task').start()
     self.Task.return_value.assertHost = mock.MagicMock()
     self.get_build = mock.patch('kojihub.get_build').start()
     self.get_maven_build = mock.patch('kojihub.get_maven_build').start()
     self.get_archive_type = mock.patch('kojihub.get_archive_type').start()
     mock.patch('kojihub.lookup_name', new=self.my_lookup_name).start()
     mock.patch.object(kojihub.BuildRoot,
                       'load',
                       new=self.my_buildroot_load).start()
     mock.patch('kojihub.import_archive_internal',
                new=self.my_import_archive_internal).start()
     mock.patch('kojihub._dml').start()
     mock.patch('kojihub._fetchSingle').start()
     mock.patch('kojihub.build_notification').start()
     mock.patch('kojihub.assert_policy').start()
     mock.patch('kojihub.check_volume_policy',
                return_value={
                    'id': 0,
                    'name': 'DEFAULT'
                }).start()
     self.set_up_callbacks()
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.pathinfo = koji.PathInfo(self.tempdir)
     mock.patch('koji.pathinfo', new=self.pathinfo).start()
     self.hostcalls = kojihub.HostExports()
     self.context = mock.patch('kojihub.context').start()
     mock.patch('kojihub.Host').start()
     self.Task = mock.patch('kojihub.Task').start()
     self.Task.return_value.assertHost = mock.MagicMock()
     self.get_build = mock.patch('kojihub.get_build').start()
     mock.patch('kojihub.get_rpm', new=self.my_get_rpm).start()
     self.get_image_build = mock.patch('kojihub.get_image_build').start()
     mock.patch('kojihub.get_archive_type', new=self.my_get_archive_type).start()
     mock.patch('kojihub.lookup_name', new=self.my_lookup_name).start()
     mock.patch.object(kojihub.BuildRoot, 'load', new=self.my_buildroot_load).start()
     mock.patch('kojihub.import_archive_internal',
                 new=self.my_import_archive_internal).start()
     self._dml = mock.patch('kojihub._dml').start()
     mock.patch('kojihub.build_notification').start()
     mock.patch('kojihub.assert_policy').start()
     mock.patch('kojihub.check_volume_policy',
             return_value={'id':0, 'name': 'DEFAULT'}).start()
     self.set_up_callbacks()
     self.rpms = {}
     self.inserts = []
     self.updates = []
     mock.patch.object(kojihub.InsertProcessor, 'execute',
                 new=make_insert_grabber(self)).start()
     mock.patch.object(kojihub.BulkInsertProcessor, '_one_insert',
                 new=make_bulk_insert_grabber(self)).start()
     mock.patch.object(kojihub.UpdateProcessor, 'execute',
                 new=make_update_grabber(self)).start()
     mock.patch('kojihub.nextval', new=self.my_nextval).start()
     self.sequences = {}
 def test_distRepoMove(self):
     exports = kojihub.HostExports()
     exports.distRepoMove(self.rinfo['id'], self.uploadpath, self.arch)
     # check result
     repodir = self.topdir + '/repos-dist/%(tag_name)s/%(id)s' % self.rinfo
     for relpath in self.expected:
         path = os.path.join(repodir, relpath)
         basename = os.path.basename(path)
         if not os.path.exists(path):
             raise Exception("Missing file: %s" % path)
         data = open(path).read()
         data.strip()
         self.assertEquals(data, basename)
Exemplo n.º 4
0
 def test_distRepoMove(self):
     session = kojihub.context.session = mock.MagicMock()
     session.user_id = 123
     exports = kojihub.HostExports()
     exports.distRepoMove(self.rinfo['id'], self.uploadpath, self.arch)
     # check result
     repodir = self.topdir + '/repos-dist/%(tag_name)s/%(id)s' % self.rinfo
     for relpath in self.expected:
         path = os.path.join(repodir, relpath)
         basename = os.path.basename(path)
         if not os.path.exists(path):
             raise Exception("Missing file: %s" % path)
         data = open(path, 'rt', encoding='utf-8').read()
         data.strip()
         self.assertEqual(data, basename)
Exemplo n.º 5
0
def get_registry(opts, plugins):
    # Create and populate handler registry
    registry = HandlerRegistry()
    functions = kojihub.RootExports()
    hostFunctions = kojihub.HostExports()
    registry.register_instance(functions)
    registry.register_module(hostFunctions,"host")
    registry.register_function(koji.auth.login)
    registry.register_function(koji.auth.krbLogin)
    registry.register_function(koji.auth.sslLogin)
    registry.register_function(koji.auth.logout)
    registry.register_function(koji.auth.subsession)
    registry.register_function(koji.auth.logoutChild)
    registry.register_function(koji.auth.exclusiveSession)
    registry.register_function(koji.auth.sharedSession)
    for name in opts.get('Plugins', '').split():
        registry.register_plugin(plugins.get(name))
    return registry