本文整理汇总了Python中pulp.devel.unit.util.compare_dict函数的典型用法代码示例。如果您正苦于以下问题:Python compare_dict函数的具体用法?Python compare_dict怎么用?Python compare_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compare_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_consumer_payload
def test_create_consumer_payload(self):
local_distributor = YumHTTPDistributor()
repo = Mock()
repo.display_name = 'foo'
repo.id = 'bar'
config = {'https_ca': 'pear',
'gpgkey': 'kiwi',
'auth_cert': 'durian',
'auth_ca': True,
'http': True,
'https': True}
binding_config = {}
pulp_server_config.set('server', 'server_name', 'apple')
cert_file = os.path.join(self.working_dir, "orange_file")
with open(cert_file, 'w') as filewriter:
filewriter.write("orange")
pulp_server_config.set('security', 'ssl_ca_certificate', cert_file)
result = local_distributor.create_consumer_payload(repo, config, binding_config)
target = {
'server_name': 'apple',
'ca_cert': 'orange',
'relative_path': '/pulp/repos/bar',
'gpg_keys': {'pulp.key': 'kiwi'},
'client_cert': 'durian',
'protocols': ['http', 'https'],
'repo_name': 'foo'
}
compare_dict(result, target)
示例2: test_get_progress_report_description
def test_get_progress_report_description(self):
step = PublishStep('bar_step')
step.description = 'bar'
step.progress_details = 'baz'
step.error_details = "foo"
step.state = reporting_constants.STATE_COMPLETE
step.total_units = 2
step.progress_successes = 1
step.progress_failures = 1
report = step.get_progress_report()
target_report = {
reporting_constants.PROGRESS_STEP_TYPE_KEY: 'bar_step',
reporting_constants.PROGRESS_NUM_SUCCESSES_KEY: 1,
reporting_constants.PROGRESS_STATE_KEY: step.state,
reporting_constants.PROGRESS_ERROR_DETAILS_KEY: step.error_details,
reporting_constants.PROGRESS_NUM_PROCESSED_KEY: 2,
reporting_constants.PROGRESS_NUM_FAILURES_KEY: 1,
reporting_constants.PROGRESS_ITEMS_TOTAL_KEY: 2,
reporting_constants.PROGRESS_DESCRIPTION_KEY: 'bar',
reporting_constants.PROGRESS_DETAILS_KEY: 'baz',
reporting_constants.PROGRESS_STEP_UUID: step.uuid
}
compare_dict(report[0], target_report)
示例3: test_describe_distributors
def test_describe_distributors(self):
command = cudl.CreateDebRepositoryCommand(Mock())
user_input = {cudl.OPT_AUTO_PUBLISH.keyword: True}
result = command._describe_distributors(user_input)
target_result = {'distributor_id': constants.CLI_WEB_DISTRIBUTOR_ID,
'distributor_type_id': constants.WEB_DISTRIBUTOR_TYPE_ID,
'distributor_config': {},
'auto_publish': True}
compare_dict(result[0], target_result)
示例4: test_describe_distributors
def test_describe_distributors(self):
command = TestPythonRespositoryOptions.MixinTestClass()
user_input = {}
result = command._describe_distributors(user_input)
target_result = {'distributor_id': constants.CLI_DISTRIBUTOR_ID,
'distributor_type_id': constants.DISTRIBUTOR_TYPE_ID,
'distributor_config': {},
'auto_publish': True}
compare_dict(result[0], target_result)
示例5: test_get_publish_tasks
def test_get_publish_tasks(self):
context = mock.Mock()
resource_id = "foo"
export._get_publish_tasks(resource_id, context)
tags = ['pulp:repository_group:foo', 'pulp:action:publish']
criteria = {'filters': {'state': {'$nin': COMPLETED_STATES}, 'tags': {'$all': tags}}}
self.assertTrue(context.server.tasks_search.search.called)
created_criteria = context.server.tasks_search.search.call_args[1]
compare_dict(criteria, created_criteria)
示例6: test_to_dict
def test_to_dict(self):
test_exception = exceptions.PulpException("foo_msg")
test_exception.error_data = {"foo": "bar"}
result = test_exception.to_dict()
compare_dict(result, {'code': test_exception.error_code.code,
'description': str(test_exception),
'data': {"foo": "bar"},
'sub_errors': []})
示例7: test_get_progress_report_summary
def test_get_progress_report_summary(self):
parent_step = publish_step.PluginStep('parent_step')
step = publish_step.PluginStep('foo_step')
parent_step.add_child(step)
step.state = reporting_constants.STATE_COMPLETE
report = parent_step.get_progress_report_summary()
target_report = {
'foo_step': reporting_constants.STATE_COMPLETE
}
compare_dict(report, target_report)
示例8: test_serialize
def test_serialize(self):
async_result = AsyncResult('foo')
test_exception = PulpException('foo')
result = tasks.TaskResult('foo', test_exception, [{'task_id': 'baz'}, async_result, "qux"])
serialized = result.serialize()
self.assertEquals(serialized.get('result'), 'foo')
compare_dict(test_exception.to_dict(), serialized.get('error'))
self.assertEquals(serialized.get('spawned_tasks'), [{'task_id': 'baz'},
{'task_id': 'foo'},
{'task_id': 'qux'}])
示例9: test_process_dictionary_against_whitelisty_global_and_local_keys
def test_process_dictionary_against_whitelisty_global_and_local_keys(self):
test_dictionary = {
u'_href': u'foo',
u'_id': u'bar',
u'_ns': u'baz',
u'qux': u'quux'
}
test_dictionary_before = copy.deepcopy(test_dictionary)
JSONController.process_dictionary_against_whitelist(test_dictionary, [u'qux'])
util.compare_dict(test_dictionary_before, test_dictionary)
示例10: test_describe_distributors
def test_describe_distributors(self):
command = TestNpmRespositoryOptions.MixinTestClass()
# by default the value is set to None
user_input = {
'auto-publish': None
}
result = command._describe_distributors(user_input)
target_result = {'distributor_id': constants.CLI_DISTRIBUTOR_ID,
'distributor_type_id': constants.DISTRIBUTOR_TYPE_ID,
'distributor_config': {},
'auto_publish': True}
compare_dict(result[0], target_result)
示例11: test_post
def test_post(self, mock_get_results):
search_controller = dispatch_controller.SearchTaskCollection()
mock_get_results.return_value = [self.get_task()]
processed_tasks_json = search_controller.POST()
# Mimic the processing
updated_task = dispatch_controller.task_serializer(self.get_task())
processed_tasks = json.loads(processed_tasks_json)
compare_dict(updated_task, processed_tasks[0])
# validate the permissions
self.validate_auth(authorization.READ)
示例12: test_to_dict_nested_pulp_exception
def test_to_dict_nested_pulp_exception(self):
test_exception = exceptions.PulpException("foo_msg")
test_exception.error_data = {"foo": "bar"}
test_exception.add_child_exception(exceptions.PulpCodedException(error_codes.PLP0001))
result = test_exception.to_dict()
child_exception = result['sub_errors'][0]
compare_dict(child_exception, {'code': error_codes.PLP0001.code,
'description': error_codes.PLP0001.message,
'data': {},
'sub_errors': []})
示例13: test_get_with_association_filter
def test_get_with_association_filter(self, mock_manager_factory):
step = publish_step.UnitPublishStep("foo", ['bar', 'baz'])
step.association_filters = {'foo': 'bar'}
find_by_criteria = mock_manager_factory.repo_unit_association_query_manager.return_value.\
find_by_criteria
find_by_criteria.return_value.count.return_value = 5
total = step._get_total()
criteria_object = find_by_criteria.call_args[0][0]
compare_dict(criteria_object.filters, {'foo': 'bar',
'unit_type_id': {'$in': ['bar', 'baz']}})
self.assertEquals(5, total)
示例14: test_process_dictionary_against_whitelist_filter_key
def test_process_dictionary_against_whitelist_filter_key(self):
test_dictionary = {
u'_href': u'foo',
u'_id': u'bar',
u'_ns': u'baz',
u'qux': u'quux'
}
target_result = copy.deepcopy(test_dictionary)
target_result.pop(u'qux', None)
JSONController.process_dictionary_against_whitelist(test_dictionary, [])
util.compare_dict(target_result, test_dictionary)
示例15: test_distributor_update_no_bindings
def test_distributor_update_no_bindings(self, mock_dist_manager, mock_bind_manager):
config = {'configvalue': 'baz'}
generated_distributor = {'foo': 'bar'}
mock_dist_manager.return_value.update_distributor_config.return_value = \
generated_distributor
#Use None for the delta value to ensure it doesn't throw an exception
result = repository.distributor_update('foo-id', 'bar-id', config, None)
mock_dist_manager.return_value.update_distributor_config. \
assert_called_with('foo-id', 'bar-id', config, None)
self.assertTrue(isinstance(result, TaskResult))
util.compare_dict(generated_distributor, result.return_value)
self.assertEquals(None, result.error)