def test_read_existing(self): self.idb.add(self.recipe) self.idb.write() new_idb = InstallDB(self.idb.filename) entry = new_idb.get('ag') assert entry is not None assert entry['hash'] == self.recipe.repo.src_hash
def test_read(self): self.idb.add(self.recipe) self.idb.write() self.idb.read() self.idb = InstallDB(self.idb_file) entry = self.idb.get('ag') assert entry is not None assert entry['hash'] == self.recipe.repo.src_hash
class TestInstallDB(object): def setup(self): self.config = tc.CONF self.idb_file = os.path.join(tc.STAGING, 'test_idb.yml') self.idb = InstallDB(self.idb_file) self.recipe = pakit.recipe.RDB.get('ag') def teardown(self): tc.delete_it(self.idb_file) def test_add(self): self.idb.add(self.recipe) ag_recipe = self.idb.get('ag') assert ag_recipe['hash'] == self.recipe.repo.src_hash def test_get(self): self.idb.add(self.recipe) assert self.idb.get('ag') is not None assert self.idb.get('ag')['hash'] == self.recipe.repo.src_hash self.idb.remove('ag') assert self.idb.get('ag') is None
def setup(self): self.config = tc.CONF self.idb_file = os.path.join(tc.STAGING, 'test_idb.yml') self.idb = InstallDB(self.idb_file) self.recipe = pakit.recipe.RDB.get('ag')
class TestInstallDB(object): def setup(self): self.config = tc.CONF self.idb_file = os.path.join(tc.STAGING, 'test_idb.yml') self.idb = InstallDB(self.idb_file) self.recipe = pakit.recipe.RDB.get('ag') def teardown(self): tc.delete_it(self.idb_file) def test__str__(self): expect = [ 'Config File: ' + self.idb_file, 'Contents:', '{', ' "ag": {', ' "hash": "d7193e13a7f8f9fe9732e1f546a39e45d3925eb3",', ' "repo": "stable",', ' }', '}' ] self.recipe.repo = 'stable' self.idb.add(self.recipe) print(str(self.idb)) lines = str(self.idb).split('\n') del lines[7] del lines[4] assert expect == lines def test__contains__(self): self.idb.set('ag', {'hello': 'world'}) assert 'ag' in self.idb assert 'moose' not in self.idb def test__iter__(self): self.idb.set('ack', 'ack') self.idb.set('ag', 'ag') actual = sorted([key + obj for key, obj in self.idb]) assert actual == ['ackack', 'agag'] def test__delitem__(self): self.idb.add(self.recipe) assert self.idb['ag']['hash'] == self.recipe.repo.src_hash del self.idb['ag'] with pytest.raises(KeyError): self.idb['ag'] def test__getitem__(self): self.idb.add(self.recipe) assert self.idb['ag']['hash'] == self.recipe.repo.src_hash self.idb.remove('ag') with pytest.raises(KeyError): self.idb['ag'] def test_add(self): self.idb.add(self.recipe) ag = self.idb.get('ag') assert ag['hash'] == self.recipe.repo.src_hash def test_set(self): self.idb.set('ag', {'hello': 'world'}) entry = self.idb.get('ag') assert entry['hello'] == 'world' def test_get(self): self.idb.add(self.recipe) assert self.idb.get('ag') is not None assert self.idb.get('ag')['hash'] == self.recipe.repo.src_hash self.idb.remove('ag') assert self.idb.get('ag') is None def test_remove(self): self.idb.add(self.recipe) self.idb.remove('ag') assert self.idb.get('ag') is None def test_write(self): self.idb.add(self.recipe) self.idb.write() assert os.path.exists(self.idb_file) def test_read(self): self.idb.add(self.recipe) self.idb.write() self.idb.read() self.idb = InstallDB(self.idb_file) entry = self.idb.get('ag') assert entry is not None assert entry['hash'] == self.recipe.repo.src_hash def test_read_existing(self): self.idb.add(self.recipe) self.idb.write() new_idb = InstallDB(self.idb.filename) entry = new_idb.get('ag') assert entry is not None assert entry['hash'] == self.recipe.repo.src_hash