示例#1
0
文件: mock.py 项目: jucke/mock
def do_debugconfig(config_opts, uidManager):
    jinja_expand = config_opts['__jinja_expand']
    defaults = util.load_defaults(uidManager, __VERSION__, PKGPYTHONDIR)
    defaults['__jinja_expand'] = False
    config_opts['__jinja_expand'] = False
    for key in sorted(config_opts):
        if key == '__jinja_expand':
            value = jinja_expand
        else:
            value = config_opts[key]
        if (key in defaults) and (key in config_opts) and (config_opts[key] != defaults[key]) or \
           (key not in defaults):
            print("config_opts['{}'] = {}".format(key, pformat(value)))
    config_opts['__jinja_expand'] = jinja_expand
    def setup_method(self, method):
        self.workdir = tempfile.mkdtemp(prefix='mock-test')

        testdir = os.path.dirname(os.path.realpath(__file__))
        plugindir = os.path.join(testdir, '..', 'py', 'mockbuild')
        plugindir = os.path.realpath(plugindir)

        self.config_opts = load_defaults(None, 'git', plugindir)
        self.config_opts['root'] = 'distro-version-arch'
        self.config_opts['basedir'] = self.workdir
        self.config_opts["resultdir"] = "{{basedir}}/{{root}}/result"
        self.config_opts['chroothome'] = '/builddir'
        self.config_opts['chrootgid'] = '135'
        self.config_opts['package_manager'] = 'dnf'
        self.config_opts['releasever'] = '1'
        self.config_opts['target_arch'] = 'fakearch'
        self.config_opts['dnf_vars'] = {'test': 'testval'}

        with mock.patch('mockbuild.buildroot.package_manager'):
            with mock.patch('mockbuild.util.cmpKernelVer') as kv:
                kv.return_value = True
                self.bootstrap_buildroot = Buildroot(
                    self.config_opts.copy(),
                    None,  # state
                    MagicMock(),  # state
                    MagicMock(),  # plugins
                    None,  # bootstrap_buildroot
                    True,  # is_bootstrap
                )

                self.buildroot = Buildroot(
                    self.config_opts,
                    None,  # uidManager
                    MagicMock(),  # state
                    MagicMock(),  # plugins
                    self.bootstrap_buildroot,
                    False,  # is_bootstrap
                )

        self.package_manager = _PackageManager(self.buildroot.config,
                                               self.buildroot,
                                               self.buildroot.plugins,
                                               self.bootstrap_buildroot, False)

        self.package_manager_bootstrap = _PackageManager(
            self.bootstrap_buildroot.config, self.bootstrap_buildroot,
            self.bootstrap_buildroot.plugins, self.buildroot.plugins, False)