本文整理汇总了Python中pulp_docker.plugins.importers.importer.DockerImporter类的典型用法代码示例。如果您正苦于以下问题:Python DockerImporter类的具体用法?Python DockerImporter怎么用?Python DockerImporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DockerImporter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TestSyncRepo
class TestSyncRepo(unittest.TestCase):
def setUp(self):
super(TestSyncRepo, self).setUp()
self.repo = Repository('repo1', working_dir='/a/b/c')
self.repo.repo_obj = model.Repository(repo_id=self.repo.id)
self.sync_conduit = mock.MagicMock()
self.config = mock.MagicMock()
self.importer = DockerImporter()
@mock.patch('pulp_docker.plugins.importers.sync.SyncStep')
@mock.patch('pulp.plugins.util.publish_step.common_utils.get_working_directory',
mock.MagicMock(return_value='/a/b/c'))
def test_calls_sync_step(self, mock_sync_step, mock_rmtree, mock_mkdtemp):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.assert_called_once_with(
repo=self.repo, conduit=self.sync_conduit,
config=self.config)
@mock.patch('pulp_docker.plugins.importers.sync.SyncStep')
@mock.patch('pulp.plugins.util.publish_step.common_utils.get_working_directory',
mock.MagicMock(return_value='/a/b/c'))
def test_calls_sync(self, mock_sync_step, mock_rmtree, mock_mkdtemp):
"""
Assert that the sync_repo() method calls sync() on the SyncStep.
"""
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.return_value.process_lifecycle.assert_called_once_with()
开发者ID:shubham90,项目名称:pulp_docker,代码行数:29,代码来源:test_importer.py
示例2: test_import_all_manifests
def test_import_all_manifests(self):
units = [
mock.Mock(
type_id=constants.MANIFEST_TYPE_ID,
unit_key={'digest': 'A1234'},
metadata={'fs_layers': []}),
mock.Mock(
type_id=constants.MANIFEST_TYPE_ID,
unit_key={'digest': 'B1234'},
metadata={'fs_layers': []}),
]
conduit = mock.Mock()
conduit.get_source_units.side_effect = [units, []]
# test
importer = DockerImporter()
importer._import_manifests(conduit, None)
# validation
self.assertEqual(
conduit.associate_unit.call_args_list,
[
mock.call(units[0]),
mock.call(units[1]),
])
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:25,代码来源:test_importer.py
示例3: test_import_manifests
def test_import_manifests(self, criteria):
layers = [
{'blobSum': 'b2244'},
{'blobSum': 'b2245'},
{'blobSum': 'b2246'}
]
units = [
# ignored
mock.Mock(type_id=constants.IMAGE_TYPE_ID),
# manifests
mock.Mock(
type_id=constants.MANIFEST_TYPE_ID,
unit_key={'digest': 'A1234'},
metadata={'fs_layers': []}
),
mock.Mock(
type_id=constants.MANIFEST_TYPE_ID,
unit_key={'digest': 'B1234'},
metadata={'fs_layers': layers}
),
mock.Mock(
type_id=constants.MANIFEST_TYPE_ID,
unit_key={'digest': 'C1234'},
metadata={'fs_layers': layers}
),
]
conduit = mock.Mock()
blobs = [dict(digest=l.values()[0]) for l in layers]
conduit.get_source_units.return_value = blobs
# test
importer = DockerImporter()
units_added = importer._import_manifests(conduit, units)
# validation
blob_filter = {
'digest': {
'$in': [l.values()[0] for l in layers]
}
}
self.assertEqual(units_added, units[1:] + blobs)
self.assertEqual(
criteria.call_args_list,
[
mock.call(type_ids=[constants.BLOB_TYPE_ID], unit_filters=blob_filter),
])
self.assertEqual(
conduit.associate_unit.call_args_list,
[
mock.call(units[1]),
mock.call(units[2]),
mock.call(units[3]),
mock.call(blobs[0]),
mock.call(blobs[1]),
mock.call(blobs[2]),
])
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:57,代码来源:test_importer.py
示例4: test_call
def test_call(self, purge_blobs, purge_tags, mock_repo_qs):
repo = mock.Mock()
config = mock.Mock()
units = mock.Mock()
importer = DockerImporter()
importer.remove_units(repo, units, config)
purge_tags.assert_called_once_with(repo, units)
purge_blobs.assert_called_once_with(repo, units)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:10,代码来源:test_importer.py
示例5: TestSyncRepo
class TestSyncRepo(unittest.TestCase):
def setUp(self):
super(TestSyncRepo, self).setUp()
self.repo = Repository('repo1', working_dir='/a/b/c')
self.sync_conduit = mock.MagicMock()
self.config = mock.MagicMock()
self.importer = DockerImporter()
def test_calls_sync_step(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.assert_called_once_with(repo=self.repo, conduit=self.sync_conduit,
config=self.config,
working_dir=mock_mkdtemp.return_value)
def test_calls_sync(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.return_value.sync.assert_called_once_with()
@mock.patch('pulp_docker.plugins.importers.v1_sync.SyncStep')
def test_fall_back_to_v1(self, v1_sync_step, mock_rmtree, mock_mkdtemp, mock_sync_step):
"""
Ensure that the sync_repo() method falls back to Docker v1 if Docker v2 isn't available.
"""
# Simulate the v2 API being unavailable
mock_sync_step.side_effect = NotImplementedError()
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
v1_sync_step.assert_called_once_with(
repo=self.repo, conduit=self.sync_conduit, config=self.config,
working_dir=mock_mkdtemp.return_value)
v1_sync_step.return_value.sync.assert_called_once_with()
def test_makes_temp_dir(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_mkdtemp.assert_called_once_with(dir=self.repo.working_dir)
def test_removes_temp_dir(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_rmtree.assert_called_once_with(mock_mkdtemp.return_value, ignore_errors=True)
def test_removes_temp_dir_after_exception(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
class MyError(Exception):
pass
mock_sync_step.return_value.sync.side_effect = MyError
self.assertRaises(MyError, self.importer.sync_repo, self.repo,
self.sync_conduit, self.config)
mock_rmtree.assert_called_once_with(mock_mkdtemp.return_value, ignore_errors=True)
开发者ID:twaugh,项目名称:pulp_docker,代码行数:53,代码来源:test_importer.py
示例6: TestCancel
class TestCancel(unittest.TestCase):
def setUp(self):
super(TestCancel, self).setUp()
self.importer = DockerImporter()
def test_calls_cancel(self):
self.importer.sync_step = mock.MagicMock()
self.importer.cancel_sync_repo()
# make sure the step's cancel method was called
self.importer.sync_step.cancel.assert_called_once_with()
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:12,代码来源:test_importer.py
示例7: test_calls_process_lifecycle
def test_calls_process_lifecycle(self, m_repo_objects, m_step):
repo = mock.Mock(id='repo1')
conduit = mock.MagicMock()
config = mock.MagicMock()
importer = DockerImporter()
repo_instance = Repository()
m_repo_objects.get_repo_or_missing_resource.return_value = repo_instance
importer.upload_unit(repo, constants.IMAGE_TYPE_ID, {}, {}, 'foo/path', conduit, config)
m_step.assert_called_once_with(repo=repo_instance,
file_path='foo/path',
config=config)
m_step.return_value.process_lifecycle.assert_called_once_with()
开发者ID:jeremycline,项目名称:pulp_docker,代码行数:13,代码来源:test_importer.py
示例8: test_purge_orphaned
def test_purge_orphaned(self, query_manager, association_manager, criteria):
repo = mock.Mock()
blobs = [
{'blobSum': 'blob-0'}, # manifest => 1
{'blobSum': 'blob-1'}, # manifest => 1
{'blobSum': 'blob-2'}, # manifest => 1
{'blobSum': 'blob-3'}, # manifest => 1, 2, 3 (not orphaned)
{'blobSum': 'blob-4'}, # manifest => 1, 2
{'blobSum': 'blob-5'}, # manifest => 2, 4 (not orphaned)
{'blobSum': 'blob-6'}, # manifest => 2
]
removed = [
mock.Mock(
id='manifest-1',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[0:4]}),
mock.Mock(
id='manifest-2',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[2:8]})
]
others = [
mock.Mock(
id='manifest-3',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[3:4]}),
mock.Mock(
id='manifest-4',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[5:6]})
]
query_manager.return_value.get_units_by_type.return_value = others
# test
importer = DockerImporter()
importer._purge_orphaned_blobs(repo, removed)
# validation
criteria.assert_called_once_with(
type_ids=[constants.BLOB_TYPE_ID],
unit_filters={'digest': {'$in': ['blob-0', 'blob-1', 'blob-2', 'blob-4', 'blob-6']}})
query_manager.return_value.get_units_by_type.assert_called_once_with(
repo.id, constants.MANIFEST_TYPE_ID)
association_manager.return_value.unassociate_by_criteria(
repo_id=repo.id,
criteria=criteria.return_value,
owner_type='', # unused
owner_id='', # unused
notify_plugins=False)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:51,代码来源:test_importer.py
示例9: test_import
def test_import(self, import_manifests, import_images):
import_images.return_value = [1, 2]
import_manifests.return_value = [3, 4]
units = mock.Mock()
importer = DockerImporter()
imported = importer.import_units(
source_repo=self.source_repo,
dest_repo=self.dest_repo,
import_conduit=self.conduit,
config=self.config,
units=units)
import_images.assert_called_once_with(self.conduit, units)
import_manifests.assert_called_once_with(self.conduit, units)
self.assertEqual(imported, import_images.return_value + import_manifests.return_value)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:14,代码来源:test_importer.py
示例10: test_purge_not_manifests
def test_purge_not_manifests(self, query_manager, association_manager, criteria):
repo = mock.Mock()
removed = [
mock.Mock(type_id=constants.IMAGE_TYPE_ID),
mock.Mock(type_id=constants.IMAGE_TYPE_ID),
]
# test
importer = DockerImporter()
importer._purge_orphaned_blobs(repo, removed)
# validation
self.assertFalse(query_manager.called)
self.assertFalse(criteria.called)
self.assertFalse(association_manager.called)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:15,代码来源:test_importer.py
示例11: setUp
def setUp(self):
super(TestSyncRepo, self).setUp()
self.repo = Repository('repo1', working_dir='/a/b/c')
self.repo.repo_obj = model.Repository(repo_id=self.repo.id)
self.sync_conduit = mock.MagicMock()
self.config = mock.MagicMock()
self.importer = DockerImporter()
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:7,代码来源:test_importer.py
示例12: test_metadata
def test_metadata(self):
metadata = DockerImporter.metadata()
self.assertEqual(metadata['id'], constants.IMPORTER_TYPE_ID)
self.assertEqual(
set(metadata['types']),
set([constants.BLOB_TYPE_ID, constants.IMAGE_TYPE_ID, constants.MANIFEST_TYPE_ID,
constants.TAG_TYPE_ID]))
self.assertTrue(len(metadata['display_name']) > 0)
开发者ID:shubham90,项目名称:pulp_docker,代码行数:9,代码来源:test_importer.py
示例13: test_purge_orphaned_nothing_orphaned
def test_purge_orphaned_nothing_orphaned(self, query_manager, association_manager, criteria):
repo = mock.Mock()
removed = [
mock.Mock(
id='manifest-1',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': []}),
mock.Mock(
id='manifest-2',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': []})
]
# test
importer = DockerImporter()
importer._purge_orphaned_blobs(repo, removed)
# validation
self.assertFalse(query_manager.called)
self.assertFalse(criteria.called)
self.assertFalse(association_manager.called)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:21,代码来源:test_importer.py
示例14: test_metadata
def test_metadata(self):
metadata = DockerImporter.metadata()
self.assertEqual(metadata['id'], constants.IMPORTER_TYPE_ID)
self.assertEqual(
metadata['types'],
[
models.Image.TYPE_ID,
models.Manifest.TYPE_ID,
models.Blob.TYPE_ID
])
self.assertTrue(len(metadata['display_name']) > 0)
开发者ID:twaugh,项目名称:pulp_docker,代码行数:12,代码来源:test_importer.py
示例15: test_purge_orphaned_all_adopted
def test_purge_orphaned_all_adopted(self, query_manager, association_manager, criteria):
repo = mock.Mock()
blobs = [
{'blobSum': 'blob-0'}, # manifest => 1, 3 (not orphaned)
{'blobSum': 'blob-1'}, # manifest => 1, 3 (not orphaned)
{'blobSum': 'blob-2'}, # manifest => 1, 3 (not orphaned)
{'blobSum': 'blob-3'}, # manifest => 1, 2, 3 (not orphaned)
{'blobSum': 'blob-4'}, # manifest => 1, 2, 3 (not orphaned)
{'blobSum': 'blob-5'}, # manifest => 2, 4, 3 (not orphaned)
{'blobSum': 'blob-6'}, # manifest => 2, 3 (not orphaned)
]
removed = [
mock.Mock(
id='manifest-1',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[0:4]}),
mock.Mock(
id='manifest-2',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs[2:8]})
]
others = [
mock.Mock(
id='manifest-3',
type_id=constants.MANIFEST_TYPE_ID,
metadata={'fs_layers': blobs}),
]
query_manager.return_value.get_units_by_type.return_value = others
# test
importer = DockerImporter()
importer._purge_orphaned_blobs(repo, removed)
# validation
self.assertFalse(criteria.called)
self.assertFalse(association_manager.called)
开发者ID:maxamillion,项目名称:pulp_docker,代码行数:37,代码来源:test_importer.py
示例16: TestSyncRepo
class TestSyncRepo(unittest.TestCase):
def setUp(self):
super(TestSyncRepo, self).setUp()
self.repo = Repository('repo1', working_dir='/a/b/c')
self.sync_conduit = mock.MagicMock()
self.config = mock.MagicMock()
self.importer = DockerImporter()
def test_calls_sync_step(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.assert_called_once_with(repo=self.repo, conduit=self.sync_conduit,
config=self.config,
working_dir=mock_mkdtemp.return_value)
def test_calls_sync(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_sync_step.return_value.sync.assert_called_once_with()
def test_makes_temp_dir(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_mkdtemp.assert_called_once_with(dir=self.repo.working_dir)
def test_removes_temp_dir(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
mock_rmtree.assert_called_once_with(mock_mkdtemp.return_value, ignore_errors=True)
def test_removes_temp_dir_after_exception(self, mock_rmtree, mock_mkdtemp, mock_sync_step):
class MyError(Exception):
pass
mock_sync_step.return_value.sync.side_effect = MyError
self.assertRaises(MyError, self.importer.sync_repo, self.repo,
self.sync_conduit, self.config)
mock_rmtree.assert_called_once_with(mock_mkdtemp.return_value, ignore_errors=True)
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:38,代码来源:test_importer.py
示例17: TestSyncRepo
class TestSyncRepo(unittest.TestCase):
def setUp(self):
super(TestSyncRepo, self).setUp()
self.repo = Repository('repo1', working_dir='/a/b/c')
self.sync_conduit = mock.MagicMock()
self.config = mock.MagicMock()
self.importer = DockerImporter()
@mock.patch('pulp.plugins.util.publish_step.common_utils.get_working_directory',
mock.MagicMock(return_value='/a/b/c'))
def test_calls_sync_step(self, objects, mock_rmtree, mock_mkdtemp, v1_sync_step):
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
v1_sync_step.assert_called_once_with(
repo=objects.get_repo_or_missing_resource.return_value, conduit=self.sync_conduit,
config=self.config)
objects.get_repo_or_missing_resource.assert_called_once_with(self.repo.id)
@mock.patch('pulp.plugins.util.publish_step.common_utils.get_working_directory',
mock.MagicMock(return_value='/a/b/c'))
def test_calls_sync(self, objects, mock_rmtree, mock_mkdtemp, v1_sync_step):
"""
Assert that the sync_repo() method calls sync() on the SyncStep.
"""
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
objects.get_repo_or_missing_resource.assert_called_once_with(self.repo.id)
v1_sync_step.return_value.process_lifecycle.assert_called_once_with()
@mock.patch('pulp_docker.plugins.importers.sync.SyncStep')
def test_fall_back_to_v1(self, sync_step, objects, mock_rmtree, mock_mkdtemp, v1_sync_step):
"""
Ensure that the sync_repo() method falls back to Docker v1 if Docker v2 isn't available.
"""
# Simulate the v2 API being unavailable
sync_step.side_effect = NotImplementedError()
self.importer.sync_repo(self.repo, self.sync_conduit, self.config)
objects.get_repo_or_missing_resource.assert_called_once_with(self.repo.id)
v1_sync_step.assert_called_once_with(
repo=objects.get_repo_or_missing_resource.return_value, conduit=self.sync_conduit,
config=self.config)
v1_sync_step.return_value.process_lifecycle.assert_called_once_with()
开发者ID:jortel,项目名称:pulp_docker,代码行数:44,代码来源:test_importer.py
示例18: test_metadata
def test_metadata(self):
metadata = DockerImporter.metadata()
self.assertEqual(metadata['id'], constants.IMPORTER_TYPE_ID)
self.assertEqual(metadata['types'], [constants.IMAGE_TYPE_ID])
self.assertTrue(len(metadata['display_name']) > 0)
开发者ID:jeremycline,项目名称:pulp_docker,代码行数:6,代码来源:test_importer.py
注:本文中的pulp_docker.plugins.importers.importer.DockerImporter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论