def setUpClass(cls): docker_directory_path = os.path.join('test_data', 'docker') if not os.path.isdir(docker_directory_path): docker_tar = os.path.join('test_data', 'aufs.tgz') tar = tarfile.open(docker_tar, 'r:gz') tar.extractall('test_data') tar.close() de_test_object = de.DockerExplorer() de_test_object.docker_directory = docker_directory_path cls.storage = de_test_object.DetectStorage() cls.container_id = ( '7b02fb3e8a665a63e32b909af5babb7d6ba0b64e10003b2d9534c7d5f2af8966') cls.image_id = ( '7968321274dc6b6171697c33df7815310468e694ac5be0ec03ff053bb135e768')
def setUpClass(cls): docker_directory_path = os.path.join('test_data', 'docker') if not os.path.isdir(docker_directory_path): docker_tar = os.path.join('test_data', 'overlay.tgz') tar = tarfile.open(docker_tar, 'r:gz') tar.extractall('test_data') tar.close() de_test_object = de.DockerExplorer() de_test_object.docker_directory = docker_directory_path cls.storage = de_test_object.DetectStorage() cls.container_id = ( '5dc287aa80b460652a5584e80a5c8c1233b0c0691972d75424cf5250b917600a') cls.image_id = ( '5b0d59026729b68570d99bc4f3f7c31a2e4f2a5736435641565d93e7c25bd2c3')
def setUpClass(cls): docker_directory_path = os.path.join('test_data', 'docker') if not os.path.isdir(docker_directory_path): docker_tar = os.path.join('test_data', 'overlay2.tgz') tar = tarfile.open(docker_tar, 'r:gz') tar.extractall('test_data') tar.close() de_test_object = de.DockerExplorer() de_test_object.docker_directory = docker_directory_path cls.storage = de_test_object.DetectStorage() cls.container_id = ( '8e8b7f23eb7cbd4dfe7e91646ddd0e0f524218e25d50113559f078dfb2690206') cls.image_id = ( '8ac48589692a53a9b8c2d1ceaa6b402665aa7fe667ba51ccc03002300856d8c7')
def testParseArguments(self): de_test_object = de.DockerExplorer() prog = sys.argv[0] expected_docker_root = os.path.join('test_data', 'docker') args = [prog, '-r', expected_docker_root, 'list', 'repositories'] sys.argv = args options = de_test_object.ParseArguments() usage_string = de_test_object._argument_parser.format_usage() expected_usage = ('usage: {0} [-h] [-r DOCKER_DIRECTORY] ' '{{mount,list,history}} ...\n'.format( os.path.basename(__file__))) self.assertEqual(expected_usage, usage_string) de_test_object.ParseOptions(options) self.assertEqual(expected_docker_root, options.docker_directory)
def testDetectStorage(self): de_test_object = de.DockerExplorer() de_test_object.docker_directory = 'this_dir_shouldnt_exist' expected_error_message = ( '{0:s} is not a Docker directory\n' 'Please specify the Docker\'s directory path.\n' 'hint: python {1:s} -r /var/lib/docker').format( de_test_object.docker_directory, sys.argv[0]) with self.assertRaises(de.BadStorageException) as err: de_test_object.DetectStorage() self.assertEqual(expected_error_message, err.exception.message) de_test_object.docker_directory = os.path.join('test_data', 'docker') storage_object = de_test_object.DetectStorage() self.assertIsNotNone(storage_object) self.assertIsInstance(storage_object, overlay.OverlayStorage) self.assertEqual(storage_object.STORAGE_METHOD, 'overlay') self.assertEqual(2, storage_object.docker_version) self.assertEqual('config.v2.json', storage_object.container_config_filename)