本文整理汇总了Python中verifier.glance_verifier._verify_for_usage函数的典型用法代码示例。如果您正苦于以下问题:Python _verify_for_usage函数的具体用法?Python _verify_for_usage怎么用?Python _verify_for_usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_verify_for_usage函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_verify_exist_marks_exist_failed_if_field_mismatch_exception
def test_verify_exist_marks_exist_failed_if_field_mismatch_exception(self):
utils.mock_datetime_utcnow(self.mox, "2014-01-02 03:04:05")
exist1 = self.mox.CreateMockAnything()
exist2 = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, "_verify_for_usage")
self.mox.StubOutWithMock(glance_verifier, "_verify_for_delete")
self.mox.StubOutWithMock(glance_verifier, "_verify_validity")
entity_1 = {"name": "exists", "value": "expected"}
entity_2 = {"name": "launches", "value": "actual"}
field_mismatch_exc = FieldMismatch("field", entity_1, entity_2, "uuid")
glance_verifier._verify_for_usage(exist1).AndRaise(exception=field_mismatch_exc)
exist1.mark_failed(
reason="Failed at 2014-01-02 03:04:05 UTC for uuid: Data mismatch "
"for 'field' - 'exists' contains 'expected' but 'launches' "
"contains 'actual'"
)
glance_verifier._verify_for_usage(exist2)
glance_verifier._verify_for_delete(exist2)
glance_verifier._verify_validity(exist2)
exist2.mark_verified()
self.mox.ReplayAll()
verified, exist = glance_verifier._verify([exist1, exist2])
self.mox.VerifyAll()
self.assertFalse(verified)
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:27,代码来源:test_glance_verifier.py
示例2: test_verify_exist_marks_exist_failed_if_field_mismatch_exception
def test_verify_exist_marks_exist_failed_if_field_mismatch_exception(self):
mock_logger = self._setup_mock_logger()
self.mox.StubOutWithMock(mock_logger, 'info')
mock_logger.exception("glance: Expected field to be 'expected' "
"got 'actual'")
exist1 = self.mox.CreateMockAnything()
exist2 = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, '_verify_for_usage')
self.mox.StubOutWithMock(glance_verifier, '_verify_for_delete')
self.mox.StubOutWithMock(glance_verifier, '_verify_validity')
field_mismatch_exc = FieldMismatch('field', 'expected', 'actual')
glance_verifier._verify_for_usage(exist1).AndRaise(
exception=field_mismatch_exc)
exist1.mark_failed(reason='FieldMismatch')
glance_verifier._verify_for_usage(exist2)
glance_verifier._verify_for_delete(exist2)
glance_verifier._verify_validity(exist2)
exist2.mark_verified()
self.mox.ReplayAll()
verified, exist = glance_verifier._verify([exist1, exist2])
self.mox.VerifyAll()
self.assertFalse(verified)
开发者ID:souvikbasu,项目名称:stacktach,代码行数:27,代码来源:test_glance_verifier.py
示例3: test_verify_exist_marks_exist_failed_if_field_mismatch_exception
def test_verify_exist_marks_exist_failed_if_field_mismatch_exception(self):
self.mox.StubOutWithMock(datetime, 'datetime')
datetime.datetime.utcnow().AndReturn('2014-01-01 01:01:01')
self.mox.ReplayAll()
exist1 = self.mox.CreateMockAnything()
exist2 = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, '_verify_for_usage')
self.mox.StubOutWithMock(glance_verifier, '_verify_for_delete')
self.mox.StubOutWithMock(glance_verifier, '_verify_validity')
field_mismatch_exc = FieldMismatch('field', 'expected',
'actual', 'uuid')
glance_verifier._verify_for_usage(exist1).AndRaise(
exception=field_mismatch_exc)
exist1.mark_failed(
reason="Failed at 2014-01-01 01:01:01 UTC for uuid: Expected "
"field to be 'expected' got 'actual'")
glance_verifier._verify_for_usage(exist2)
glance_verifier._verify_for_delete(exist2)
glance_verifier._verify_validity(exist2)
exist2.mark_verified()
self.mox.ReplayAll()
verified, exist = glance_verifier._verify([exist1, exist2])
self.mox.VerifyAll()
self.assertFalse(verified)
开发者ID:DragonDM,项目名称:stacktach,代码行数:28,代码来源:test_glance_verifier.py
示例4: test_verify_exist_marks_exist_as_failed_if_field_mismatch_exception_is_raised
def test_verify_exist_marks_exist_as_failed_if_field_mismatch_exception_is_raised(self):
exist = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, '_verify_for_usage')
field_mismatch_exc = FieldMismatch('field', 'expected', 'actual')
glance_verifier._verify_for_usage(exist).AndRaise(exception=field_mismatch_exc)
exist.mark_failed(reason='FieldMismatch')
self.mox.ReplayAll()
verified, exist = glance_verifier._verify(exist)
self.mox.VerifyAll()
self.assertFalse(verified)
开发者ID:thomasem,项目名称:stacktach,代码行数:12,代码来源:test_glance_verifier.py
示例5: test_verify_should_verify_exists_for_usage_and_delete
def test_verify_should_verify_exists_for_usage_and_delete(self):
exist = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, '_verify_for_usage')
glance_verifier._verify_for_usage(exist)
self.mox.StubOutWithMock(glance_verifier, '_verify_for_delete')
glance_verifier._verify_for_delete(exist)
exist.mark_verified()
self.mox.ReplayAll()
verified, exist = glance_verifier._verify(exist)
self.mox.VerifyAll()
self.assertTrue(verified)
开发者ID:thomasem,项目名称:stacktach,代码行数:13,代码来源:test_glance_verifier.py
示例6: test_verify_usage_should_not_raise_exception_on_success
def test_verify_usage_should_not_raise_exception_on_success(self):
exist = self.mox.CreateMockAnything()
exist.created_at = decimal.Decimal("1.1")
exist.owner = "owner"
exist.size = 1234
exist.usage = self.mox.CreateMockAnything()
exist.usage.created_at = decimal.Decimal("1.1")
exist.usage.size = 1234
exist.usage.owner = "owner"
self.mox.ReplayAll()
glance_verifier._verify_for_usage(exist)
self.mox.VerifyAll()
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:15,代码来源:test_glance_verifier.py
示例7: test_verify_usage_for_late_usage
def test_verify_usage_for_late_usage(self):
exist = self.mox.CreateMockAnything()
exist.usage = None
exist.uuid = IMAGE_UUID_1
exist.created_at = decimal.Decimal("1.1")
results = self.mox.CreateMockAnything()
models.ImageUsage.objects.filter(uuid=IMAGE_UUID_1).AndReturn(results)
results.count().AndReturn(1)
usage = self.mox.CreateMockAnything()
results.__getitem__(0).AndReturn(usage)
usage.created_at = decimal.Decimal("1.1")
self.mox.ReplayAll()
glance_verifier._verify_for_usage(exist)
self.mox.VerifyAll()
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:15,代码来源:test_glance_verifier.py
示例8: test_verify_usage_owner_mismatch
def test_verify_usage_owner_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.usage = self.mox.CreateMockAnything()
exist.owner = 'owner'
exist.usage.owner = 'not_owner'
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
self.assertEqual(exception.field_name, 'owner')
self.assertEqual(exception.expected, 'owner')
self.assertEqual(exception.actual, 'not_owner')
self.mox.VerifyAll()
开发者ID:thomasem,项目名称:stacktach,代码行数:15,代码来源:test_glance_verifier.py
示例9: test_verify_usage_created_at_mismatch
def test_verify_usage_created_at_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.usage = self.mox.CreateMockAnything()
exist.created_at = decimal.Decimal('1.1')
exist.usage.created_at = decimal.Decimal('2.1')
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
self.assertEqual(exception.field_name, 'created_at')
self.assertEqual(exception.expected, decimal.Decimal('1.1'))
self.assertEqual(exception.actual, decimal.Decimal('2.1'))
self.mox.VerifyAll()
开发者ID:thomasem,项目名称:stacktach,代码行数:16,代码来源:test_glance_verifier.py
示例10: test_verify_usage_created_at_mismatch
def test_verify_usage_created_at_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.usage = self.mox.CreateMockAnything()
exist.created_at = CREATED_AT_1
exist.usage.created_at = CREATED_AT_2
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
self.assertEqual(exception.field_name, "created_at")
self.assertEqual(exception.expected, CREATED_AT_1)
self.assertEqual(exception.actual, CREATED_AT_2)
self.mox.VerifyAll()
开发者ID:rcleere,项目名称:stacktach,代码行数:16,代码来源:test_glance_verifier.py
示例11: test_verify_usage_raises_not_found_for_no_usage
def test_verify_usage_raises_not_found_for_no_usage(self):
exist = self.mox.CreateMockAnything()
exist.usage = None
exist.uuid = IMAGE_UUID_1
exist.created_at = decimal.Decimal("1.1")
results = self.mox.CreateMockAnything()
models.ImageUsage.objects.filter(uuid=IMAGE_UUID_1).AndReturn(results)
results.count().AndReturn(0)
self.mox.ReplayAll()
with self.assertRaises(NotFound) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
self.assertEqual(exception.object_type, "ImageUsage")
self.assertEqual(exception.search_params, {"uuid": IMAGE_UUID_1})
self.mox.VerifyAll()
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:17,代码来源:test_glance_verifier.py
示例12: test_verify_usage_size_mismatch
def test_verify_usage_size_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.size = 1234
exist.usage = self.mox.CreateMockAnything()
exist.usage.size = 5678
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
self.assertEqual(exception.field_name, 'size')
self.assertEqual(exception.expected, 1234)
self.assertEqual(exception.actual, 5678)
self.mox.VerifyAll()
开发者ID:thomasem,项目名称:stacktach,代码行数:17,代码来源:test_glance_verifier.py
示例13: test_verify_should_verify_exists_for_usage_and_delete
def test_verify_should_verify_exists_for_usage_and_delete(self):
exist1 = self.mox.CreateMockAnything()
exist2 = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(glance_verifier, "_verify_for_usage")
self.mox.StubOutWithMock(glance_verifier, "_verify_for_delete")
self.mox.StubOutWithMock(glance_verifier, "_verify_validity")
for exist in [exist1, exist2]:
glance_verifier._verify_for_usage(exist)
glance_verifier._verify_for_delete(exist)
glance_verifier._verify_validity(exist)
exist.mark_verified()
self.mox.ReplayAll()
verified, exist = glance_verifier._verify([exist1, exist2])
self.mox.VerifyAll()
self.assertTrue(verified)
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:18,代码来源:test_glance_verifier.py
示例14: test_verify_usage_size_mismatch
def test_verify_usage_size_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.uuid = IMAGE_UUID_1
exist.size = SIZE_1
exist.usage = self.mox.CreateMockAnything()
exist.usage.size = SIZE_2
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
entity_1 = {"name": "exists", "value": SIZE_1}
entity_2 = {"name": "launches", "value": SIZE_2}
self.assertEqual(exception.field_name, "size")
self.assertEqual(exception.entity_1, entity_1)
self.assertEqual(exception.entity_2, entity_2)
self.mox.VerifyAll()
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:18,代码来源:test_glance_verifier.py
示例15: test_verify_usage_created_at_mismatch
def test_verify_usage_created_at_mismatch(self):
utils.mock_datetime_utcnow(self.mox, "2014-01-01 01:02:03")
exist = self.mox.CreateMockAnything()
exist.uuid = IMAGE_UUID_1
exist.usage = self.mox.CreateMockAnything()
exist.created_at = CREATED_AT_1
exist.usage.created_at = CREATED_AT_2
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
entity_1 = {"name": "exists", "value": CREATED_AT_1}
entity_2 = {"name": "launches", "value": CREATED_AT_2}
self.assertEqual(exception.field_name, "created_at")
self.assertEqual(exception.entity_1, entity_1)
self.assertEqual(exception.entity_2, entity_2)
self.mox.VerifyAll()
开发者ID:rainsome-org1,项目名称:stacktach,代码行数:20,代码来源:test_glance_verifier.py
示例16: test_verify_usage_owner_mismatch
def test_verify_usage_owner_mismatch(self):
utils.mock_datetime_utcnow(self.mox, '2014-01-01 01:02:03')
exist = self.mox.CreateMockAnything()
exist.uuid = IMAGE_UUID_1
exist.usage = self.mox.CreateMockAnything()
exist.owner = IMAGE_OWNER_1
exist.usage.owner = IMAGE_OWNER_2
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as cm:
glance_verifier._verify_for_usage(exist)
exception = cm.exception
entity_1 = {'name': 'exists', 'value': IMAGE_OWNER_1}
entity_2 = {'name': 'launches', 'value': IMAGE_OWNER_2}
self.assertEqual(exception.field_name, 'owner')
self.assertEqual(exception.entity_1, entity_1)
self.assertEqual(exception.entity_2, entity_2)
self.mox.VerifyAll()
开发者ID:openstack,项目名称:stacktach,代码行数:20,代码来源:test_glance_verifier.py
注:本文中的verifier.glance_verifier._verify_for_usage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论