def test_repository_creation(self, preserve=False): if not SKIP_SLOW_TESTS: with Context() as finalizers: config_dir = tempfile.mkdtemp() repo_dir = tempfile.mkdtemp() if not preserve: finalizers.register(shutil.rmtree, config_dir) finalizers.register(shutil.rmtree, repo_dir) from deb_pkg_tools import config config.user_config_directory = config_dir with open(os.path.join(config_dir, config.repo_config_file), 'w') as handle: handle.write('[test]\n') handle.write('directory = %s\n' % repo_dir) handle.write('release-origin = %s\n' % TEST_REPO_ORIGIN) self.test_package_building(repo_dir) update_repository(repo_dir, release_fields=dict(description=TEST_REPO_DESCRIPTION), cache=self.package_cache) self.assertTrue(os.path.isfile(os.path.join(repo_dir, 'Packages'))) self.assertTrue(os.path.isfile(os.path.join(repo_dir, 'Packages.gz'))) self.assertTrue(os.path.isfile(os.path.join(repo_dir, 'Release'))) with open(os.path.join(repo_dir, 'Release')) as handle: fields = Deb822(handle) self.assertEqual(fields['Origin'], TEST_REPO_ORIGIN) self.assertEqual(fields['Description'], TEST_REPO_DESCRIPTION) if not apt_supports_trusted_option(): self.assertTrue(os.path.isfile(os.path.join(repo_dir, 'Release.gpg'))) return repo_dir
def test_repository_creation(self, preserve=False): """Test the creation of trivial repositories.""" if SKIP_SLOW_TESTS: return self.skipTest("skipping slow tests") with Context() as finalizers: config_dir = tempfile.mkdtemp() repo_dir = tempfile.mkdtemp() if not preserve: finalizers.register(shutil.rmtree, config_dir) finalizers.register(shutil.rmtree, repo_dir) from deb_pkg_tools import config config.user_config_directory = config_dir with open(os.path.join(config_dir, config.repo_config_file), 'w') as handle: handle.write('[test]\n') handle.write('directory = %s\n' % repo_dir) handle.write('release-origin = %s\n' % TEST_REPO_ORIGIN) self.test_package_building(repo_dir) update_repository( repo_dir, release_fields=dict(description=TEST_REPO_DESCRIPTION), cache=self.package_cache) assert os.path.isfile(os.path.join(repo_dir, 'Packages')) assert os.path.isfile(os.path.join(repo_dir, 'Packages.gz')) assert os.path.isfile(os.path.join(repo_dir, 'Release')) with open(os.path.join(repo_dir, 'Release')) as handle: fields = Deb822(handle) assert fields['Origin'] == TEST_REPO_ORIGIN assert fields['Description'] == TEST_REPO_DESCRIPTION if not apt_supports_trusted_option(): assert os.path.isfile(os.path.join(repo_dir, 'Release.gpg')) return repo_dir