def test_gen_mock_config(self): datadir = os.path.join(os.path.dirname(__file__), 'data/mock') count = 0 for fn in os.listdir(datadir): if not fn.endswith('.data'): continue path = os.path.join(datadir, fn) with open(path) as fo: s = fo.read() params = ast.literal_eval(s) with open(path[:-5] + '.out') as fo: expected = fo.read() output = koji.genMockConfig(**params) self.assertMultiLineEqual(output, expected) count += 1 if not count: raise Exception('no test data found')
def mock_config(self, arch, tag, dist, outpath, name): tag_obj = self.kojisession.getTag(tag) if not tag_obj: raise KojiError("Invalid tag %s" % tag) config = self.kojisession.getBuildConfig(tag_obj['id']) if not config: raise KojiError("Couldn't get config for tag %s" % tag) repo = self.kojisession.getRepo(config['id']) if not repo: raise KojiError("Couldn't get repo for tag %s" % tag) opts = { 'tag_name': tag_obj['name'], 'repoid': repo['id'], 'distribution': dist, 'topurl': KOJI_HUB + "/mnt/koji" } output = kojilib.genMockConfig(name, arch, **opts) utils.unslurp(outpath, output)
def mock_config(self, target=None, arch=None): """Generate a mock config based on branch data. Can use option target and arch to override autodiscovery. Will return the mock config file text. """ if (target is None): target = self.target if (arch is None): arch = self.arch # Figure out if we have a valid build target build_target = self.kojisession.getBuildTarget(target) if not build_target: raise rpkgError('Unknown build target: %s\n' 'Consider using the --target option' % target) try: repoid = self.kojisession.getRepo( build_target['build_tag_name'])['id'] except Exception: raise rpkgError('Could not find a valid build repo') proxy = '10.144.1.10:8080' with open("/etc/yum.conf") as f: for line in f: if 'proxy' in line: proxy = line.split('=')[1] # Generate the config config = koji.genMockConfig('%s-%s' % (target, arch), arch, distribution=self.disttag, tag_name=build_target['build_tag_name'], repoid=repoid, topurl=self.topurl, yum_proxy=proxy) # Return the mess return (config)