Пример #1
0
 def test_db_recreate_empty(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     self.assertEqual([], db.list_all_by_descriptor())
     del db
     recreated_db = DB(tmp_db)
     self.assertEqual([], recreated_db.list_all_by_descriptor())
Пример #2
0
 def test_add(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
            ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     adesc = e.artifact_descriptor
     self.assertFalse(db.has_artifact(adesc))
     db.add_artifact(e)
     self.assertTrue(db.has_artifact(adesc))
Пример #3
0
 def test_remove_not_installed(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
            ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     adesc = e.artifact_descriptor
     self.assertFalse(db.has_artifact(adesc))
     with self.assertRaises(NotInstalledError) as context:
         db.remove_artifact(adesc)
Пример #4
0
 def test_list_all_by_metadata_with_build_target(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e1 = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     e2 = PM('bar-5.6.7.tar.gz', 'bar', '5.6.7', 1, 0, 'linux', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES2)
     db.add_artifact(e1)
     db.add_artifact(e2)
     self.assertEqual([e2],
                      db.list_all_by_metadata(build_target=self.LINUX_BT))
     self.assertEqual([e1],
                      db.list_all_by_metadata(build_target=self.MACOS_BT))
Пример #5
0
 def test_get(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
            ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     adesc = e.artifact_descriptor
     with self.assertRaises(NotInstalledError) as context:
         db.get_artifact(adesc)
         db.add_artifact(e)
         self.assertEqual(e, db.get_artifact(adesc))
         db.remove_artifact(adesc)
     with self.assertRaises(NotInstalledError) as context:
         db.get_artifact(adesc)
Пример #6
0
 def test_replace(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e1 = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     e2 = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES2)
     self.assertFalse(db.has_artifact(e1.artifact_descriptor))
     db.add_artifact(e1)
     self.assertTrue(db.has_artifact(e1.artifact_descriptor))
     self.assertEqual([e1.artifact_descriptor], db.list_all_by_descriptor())
     db.replace_artifact(e2)
     self.assertEqual([e2.artifact_descriptor], db.list_all_by_descriptor())
Пример #7
0
 def test_find(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
            ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     adesc = e.artifact_descriptor
     self.assertEqual(None, db.find_artifact(adesc))
     db.add_artifact(e)
     r = db.find_artifact(adesc)
     print('R: %s' % (str(r)))
     self.assertEqual(e, r)
     db.remove_artifact(adesc)
     self.assertEqual(None, db.find_artifact(adesc))
Пример #8
0
 def test_add_duplicate(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
            ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     adesc = e.artifact_descriptor
     self.assertFalse(db.has_artifact(adesc))
     db.add_artifact(e)
     self.assertTrue(db.has_artifact(adesc))
     with self.assertRaises(AlreadyInstalledError) as context:
         db.add_artifact(e)
Пример #9
0
 def test_list_all_by_descriptor(self):
     tmp_db = self._make_tmp_db_path()
     db = DB(tmp_db)
     e1 = PM('foo-1.2.3.tar.gz', 'foo', '1.2.3', 1, 0, 'macos', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES)
     e2 = PM('bar-5.6.7.tar.gz', 'bar', '5.6.7', 1, 0, 'linux', 'release',
             ('x86_64', ), '', '', [], {}, self.TEST_FILES2)
     db.add_artifact(e1)
     self.assertEqual([e1.artifact_descriptor], db.list_all_by_descriptor())
     db.add_artifact(e2)
     self.assertEqual([e2.artifact_descriptor, e1.artifact_descriptor],
                      db.list_all_by_descriptor())
Пример #10
0
from rebuild.package.artifact_db import artifact_db as DB
from rebuild.package import package_metadata as MD, artifact_descriptor as AD
from rebuild.base import build_system, build_target, package_descriptor, requirement as R, requirement_list as RL
from bes.fs import file_checksum_list

db = DB('art.db')

TEST_REQUIREMENTS = RL.parse('foo >= 1.2.3-1 bar >= 6.6.6-1',
                             default_system_mask=build_system.ALL)
TEST_FILES = file_checksum_list([('lib/libfoo.a', 'c1'),
                                 ('include/libfoo.h', 'c2')])
TEST_FILES.sort()
TEST_PROPERTIES = {'p1': 'v1', 'p2': 6}

kiwi = MD('kiwi-6.7.8-2.tar.gz', 'kiwi', '6.7.8', 2, 0, 'macos', 'release',
          ['x86_64'], '', TEST_REQUIREMENTS, TEST_PROPERTIES, TEST_FILES,
          'chk1')
apple = MD('apple-1.2.3.tar.gz', 'apple', '1.2.3', 0, 0, 'macos', 'release',
           ['x86_64'], '', TEST_REQUIREMENTS, TEST_PROPERTIES, TEST_FILES,
           'chk1')

print(db.has_artifact(kiwi.artifact_descriptor))

db.add_artifact(apple)
db.add_artifact(kiwi)

print(db.has_artifact(kiwi.artifact_descriptor))