Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.runner = MockRunner()
self.packager = ConanMultiPackager("--build missing -r conan.io",
"lasote", "mychannel",
runner=self.runner)
def testSerialize(self):
self.packager.add({"os": "Windows", "compiler": "Visual Studio"},
{"option1": "value1", "option2": "value2"})
serial = self.packager.serialize()
self.assertEquals(serial, '{"username": "lasote", "builds": [[{"os": "Windows", "compiler": "Visual Studio"}, {"option2": "value2", "option1": "value1"}]], "args": "--build missing -r conan.io", "conan_pip_package": null, "channel": "mychannel", "docker_image": null}')
mp = ConanMultiPackager.deserialize(serial, username="lasote")
self.assertEqual(mp.conan_pip_package, None)
self.packager.conan_pip_package = "conan==0.0.1rc7"
serial = self.packager.serialize()
mp = ConanMultiPackager.deserialize(serial, username="lasote")
self.assertEqual(mp.conan_pip_package, "conan==0.0.1rc7")
def test_rebuild_rootfs_format_v10(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox.tgz')
image = docker.ImageV10(test_dir)
target_dir = self.get_temp_dir()
rebuild_rootfs(image, target_dir)
expected = self.extract_test_tar('docker/v10_format/check_busybox_layer.tar')
assert testcase.is_same(target_dir, expected)
def test_rebuild_rootfs_format_v10_without_repositories_file(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox_no_repo.tgz')
image = docker.ImageV10(test_dir)
target_dir = self.get_temp_dir()
rebuild_rootfs(image, target_dir)
expected = self.extract_test_tar('docker/v10_format/check_busybox_layer.tar')
assert testcase.is_same(target_dir, expected)
def test_ImageV10(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox.tgz')
docker.ImageV10(test_dir)
def test_rebuild_rootfs_format_v10_with_delete(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox2.tgz')
image = docker.ImageV10(test_dir)
target_dir = self.get_temp_dir()
rebuild_rootfs(image, target_dir)
expected = [
'/lib/librt-0.9.33.2.so',
'/lib/libgcc_s.so.1',
'/lib/libutil-0.9.33.2.so',
'/lib/libuClibc-0.9.33.2.so',
'/lib/libm-0.9.33.2.so',
'/lib/libresolv-0.9.33.2.so',
'/lib/libnsl-0.9.33.2.so',
'/lib/libpthread-0.9.33.2.so'
]
assert sorted(expected) == sorted(f.replace(target_dir, '') for f in fileutils.file_iter(target_dir))
def test_rebuild_rootfs_format_v10_with_delete_with_out_of_order_layers(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox2.tgz')
image = docker.ImageV10(test_dir)
# shuffle artificially the layer order
image.layers = OrderedDict(sorted(image.layers.items()))
target_dir = self.get_temp_dir()
try:
rebuild_rootfs(image, target_dir)
except InconsistentLayersOderingError:
pass
def test_ImageV10_without_repositories_file(self):
test_dir = self.extract_test_tar('docker/v10_format/busybox_no_repo.tgz')
assert docker.ImageV10(test_dir)
def test_Registry(self):
Registry('assa')
def test_flatten(self):
test_arch = self.get_test_loc('repos/hello-world.tar')
test_dir = self.extract_test_tar(test_arch)
expected = os.path.join(self.get_test_loc('repos'), 'hello-world.tar.flatten.expected.json')
reg = Registry()
reg.populate(test_dir)
# ignore the repo_dir and layer_dir that are absolute directories
result = [{name: value for name, value in layer.items() if not name.endswith('dir')}
for layer in reg.flatten()]
check_expected(result, expected, regen=False)