def test_localsrcs_unset_package(self): with workdir() as test_dir: root_dir = os.path.join(test_dir, 'root') config = { 'root_dir': root_dir, } copy_template('local-src', root_dir) pkga_val = self._dummy_pkg(test_dir, 'pkg-a') # prepare local sources mode init_config = dict(config) init_config.update({ 'local_sources': [ # --local-sources set to a specific path None, # clearing path for the `pkg-b` package 'pkg-b@', ], }) with prepare_testenv(config=init_config) as engine: rv = engine.run() self.assertTrue(rv) self.assertTrue(os.path.exists(engine.opts.ff_local_srcs)) # verify desired local sources are used with prepare_testenv(config=config) as engine: rv = engine.run() self.assertTrue(rv) target_dir = engine.opts.target_dir mdf_a = os.path.join(target_dir, 'metadata-a') mdf_b = os.path.join(target_dir, 'metadata-b') mdf_c = os.path.join(target_dir, 'metadata-c') self.assertTrue(os.path.exists(mdf_a)) self.assertTrue(os.path.exists(mdf_b)) self.assertTrue(os.path.exists(mdf_c)) self._assertFileContains(mdf_a, pkga_val) self._assertFileContains(mdf_b, 'pkg-b-original') self._assertFileContains(mdf_c, 'pkg-c-original') env_a = os.path.join(target_dir, 'invoke-env-a.json') env_b = os.path.join(target_dir, 'invoke-env-b.json') env_c = os.path.join(target_dir, 'invoke-env-c.json') self.assertTrue(os.path.exists(env_a)) self.assertTrue(os.path.exists(env_b)) self.assertTrue(os.path.exists(env_c)) self._assertEnvLocalSrcs(env_a, True) self._assertEnvLocalSrcs(env_b, False) self._assertEnvLocalSrcs(env_c, False)
def test_localsrcs_per_package(self): with workdir() as root_dir, workdir() as dir_a, workdir() as dir_b: config = { 'root_dir': root_dir, } copy_template('local-src', root_dir) pkga_val = self._dummy_pkg(dir_a) pkgb_val = self._dummy_pkg(dir_b) # prepare local sources mode init_config = dict(config) init_config.update({ 'local_sources': [ # explicit path set for `pkg-a` package 'pkg-a@{}'.format(dir_a), # explicit path set for `pkg-b` package 'pkg-b@{}'.format(dir_b), ], }) with prepare_testenv(config=init_config) as engine: rv = engine.run() self.assertTrue(rv) self.assertTrue(os.path.exists(engine.opts.ff_local_srcs)) # verify desired local sources are used with prepare_testenv(config=config) as engine: rv = engine.run() self.assertTrue(rv) target_dir = engine.opts.target_dir mdf_a = os.path.join(target_dir, 'metadata-a') mdf_b = os.path.join(target_dir, 'metadata-b') mdf_c = os.path.join(target_dir, 'metadata-c') self.assertTrue(os.path.exists(mdf_a)) self.assertTrue(os.path.exists(mdf_b)) self.assertTrue(os.path.exists(mdf_c)) self._assertFileContains(mdf_a, pkga_val) self._assertFileContains(mdf_b, pkgb_val) self._assertFileContains(mdf_c, 'pkg-c-original') env_a = os.path.join(target_dir, 'invoke-env-a.json') env_b = os.path.join(target_dir, 'invoke-env-b.json') env_c = os.path.join(target_dir, 'invoke-env-c.json') self.assertTrue(os.path.exists(env_a)) self.assertTrue(os.path.exists(env_b)) self.assertTrue(os.path.exists(env_c)) self._assertEnvLocalSrcs(env_a, True) self._assertEnvLocalSrcs(env_b, True) self._assertEnvLocalSrcs(env_c, False)