def select_db(self): output = Message() config = {'output': output, 'db_type': 'xml',} db = DbBase(config, [HERE + '/testfiles/global-overlays.xml', ]) url = ['rsync://gunnarwrobel.de/wrobel-stable'] self.assertEqual(list(db.select('wrobel-stable').source_uris()), url) config['db_type'] = 'json' db = DbBase(config, [HERE + '/testfiles/global-overlays.json', ]) url = ['git://github.com/twitch153/ebuilds.git'] self.assertEqual(list(db.select('twitch153').source_uris()), url)
def select_db(self): output = Message() config = {'output': output, 'db_type': 'xml_db',} db = DbBase(config, [HERE + '/testfiles/global-overlays.xml', ]) url = ['rsync://gunnarwrobel.de/wrobel-stable'] self.assertEqual(list(db.select('wrobel-stable').source_uris()), url)
def test(self): repo_name = 'tar-test-overlay' tar_source_path = os.path.join(HERE, 'testfiles', 'layman-test.tar.bz2') # Duplicate test tarball (so we have it deletable for later) (_, temp_tarball_path) = tempfile.mkstemp() shutil.copyfile(tar_source_path, temp_tarball_path) # Write overlay collection XML xml_text = """\ <?xml version="1.0" encoding="UTF-8"?> <repositories xmlns="" version="1.0"> <repo quality="experimental" status="unofficial"> <name>%(repo_name)s</name> <description>XXXXXXXXXXX</description> <owner> <email>[email protected]</email> </owner> <source type="tar">file://%(temp_tarball_url)s</source> </repo> </repositories> """ % { 'temp_tarball_url':urllib.pathname2url(temp_tarball_path), 'repo_name':repo_name} (fd, temp_collection_path) = tempfile.mkstemp() f = os.fdopen(fd, 'w') f.write(xml_text) f.close() # Make playground directory temp_dir_path = tempfile.mkdtemp() # Make DB from it #config = {'output': Message(), 'tar_command':'/bin/tar'} config = BareConfig() db = DbBase(config, [temp_collection_path]) specific_overlay_path = os.path.join(temp_dir_path, repo_name) o = db.select('tar-test-overlay') # Actual testcase o.add(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) # (1/2) Sync with source available o.sync(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) os.unlink(temp_tarball_path) try: # (2/2) Sync with source _not_ available o.sync(temp_dir_path) except: pass self.assertTrue(os.path.exists(specific_overlay_path)) o.delete(temp_dir_path) self.assertFalse(os.path.exists(specific_overlay_path)) # Cleanup os.unlink(temp_collection_path) os.rmdir(temp_dir_path)
def select_db(self): output = Message() config = { 'output': output, 'db_type': 'xml', } db = DbBase(config, [ HERE + '/testfiles/global-overlays.xml', ]) url = ['rsync://gunnarwrobel.de/wrobel-stable'] self.assertEqual(list(db.select('wrobel-stable').source_uris()), url) config['db_type'] = 'json' db = DbBase(config, [ HERE + '/testfiles/global-overlays.json', ]) url = ['git://github.com/twitch153/ebuilds.git'] self.assertEqual(list(db.select('twitch153').source_uris()), url)
def test(self): archives = [] try: from layman.overlays.modules.tar.tar import TarOverlay archives.append('tar') from layman.overlays.modules.squashfs.squashfs import SquashfsOverlay archives.append('squashfs') except ImportError: pass for archive in archives: xml_text, repo_name, temp_archive_path = getattr(self, "_create_%(archive)s_overlay" % {'archive': archive})() (fd, temp_collection_path) = tempfile.mkstemp() with os.fdopen(fd, 'w') as f: f.write(xml_text) # Make playground directory temp_dir_path = tempfile.mkdtemp() # Make DB from it config = BareConfig() # Necessary for all mountable overlay types layman_inst = LaymanAPI(config=config) db = DbBase(config, [temp_collection_path]) specific_overlay_path = os.path.join(temp_dir_path, repo_name) o = db.select(repo_name) # Actual testcase o.add(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) # (1/2) Sync with source available o.sync(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) os.unlink(temp_archive_path) try: # (2/2) Sync with source _not_ available o.sync(temp_dir_path) except: pass self.assertTrue(os.path.exists(specific_overlay_path)) o.delete(temp_dir_path) self.assertFalse(os.path.exists(specific_overlay_path)) # Cleanup os.unlink(temp_collection_path) os.rmdir(temp_dir_path)
def test(self): archives = [] try: from layman.overlays.modules.tar.tar import TarOverlay archives.append('tar') from layman.overlays.modules.squashfs.squashfs import SquashfsOverlay archives.append('squashfs') except ImportError: pass for archive in archives: xml_text, repo_name, temp_archive_path = getattr( self, "_create_%(archive)s_overlay" % {'archive': archive})() (fd, temp_collection_path) = tempfile.mkstemp() with os.fdopen(fd, 'w') as f: f.write(xml_text) # Make playground directory temp_dir_path = tempfile.mkdtemp() # Make DB from it config = BareConfig() # Necessary for all mountable overlay types layman_inst = LaymanAPI(config=config) db = DbBase(config, [temp_collection_path]) specific_overlay_path = os.path.join(temp_dir_path, repo_name) o = db.select(repo_name) # Actual testcase o.add(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) # (1/2) Sync with source available o.sync(temp_dir_path) self.assertTrue(os.path.exists(specific_overlay_path)) os.unlink(temp_archive_path) try: # (2/2) Sync with source _not_ available o.sync(temp_dir_path) except: pass self.assertTrue(os.path.exists(specific_overlay_path)) o.delete(temp_dir_path) self.assertFalse(os.path.exists(specific_overlay_path)) # Cleanup os.unlink(temp_collection_path) os.rmdir(temp_dir_path)