def test_get_image_files_json(self): layer_id = rndstr(16) tfobj = _get_tarfile(self.filenames) layer_path = self.store.image_layer_path(layer_id) layer_path = os.path.join(self.store._root_path, layer_path) os.makedirs(os.path.dirname(layer_path)) with open(layer_path, 'w') as fobj: fobj.write(tfobj.read()) files_json = layers.get_image_files_json(layer_id) file_infos = json.loads(files_json) for info in file_infos: assert info[0] in self.filenames assert info[1:] == [u"f", False, 512, 0, 420, 0, 0]
def test_get_image_files_json(self): layer_id = rndstr(16) tfobj = _get_tarfile(self.filenames) layer_path = self.store.image_layer_path(layer_id) layer_path = os.path.join(self.store._root_path, layer_path) path_parts = layer_path.split(os.sep) path_parts[0] = '/' layer_parent = os.path.join(*path_parts[:-1]) os.makedirs(layer_parent) with open(layer_path, 'w') as fobj: fobj.write(tfobj.read()) files_json = layers.get_image_files_json(layer_id) file_infos = json.loads(files_json) for info in file_infos: self.assertIn(info[0], self.filenames) self.assertTrue(info[1:] == [u"f", False, 512, 0, 420, 0, 0])
def test_get_image_files_json_cached(self): layer_id = rndstr(16) layers.set_image_files_cache(layer_id, "{}") files_json = layers.get_image_files_json(layer_id) assert files_json == "{}"