本文整理汇总了Python中verifier.glance_verifier._verify_for_delete函数的典型用法代码示例。如果您正苦于以下问题:Python _verify_for_delete函数的具体用法?Python _verify_for_delete怎么用?Python _verify_for_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_verify_for_delete函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例4: test_verify_delete
def test_verify_delete(self):
exist = self.mox.CreateMockAnything()
exist.delete = self.mox.CreateMockAnything()
exist.deleted_at = decimal.Decimal("5.1")
exist.delete.deleted_at = decimal.Decimal("5.1")
self.mox.ReplayAll()
glance_verifier._verify_for_delete(exist)
self.mox.VerifyAll()
示例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)
示例6: test_verify_delete_deleted_at_mismatch
def test_verify_delete_deleted_at_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.delete = self.mox.CreateMockAnything()
exist.deleted_at = decimal.Decimal('5.1')
exist.delete.deleted_at = decimal.Decimal('4.1')
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as fm:
glance_verifier._verify_for_delete(exist)
exception = fm.exception
self.assertEqual(exception.field_name, 'deleted_at')
self.assertEqual(exception.expected, decimal.Decimal('5.1'))
self.assertEqual(exception.actual, decimal.Decimal('4.1'))
self.mox.VerifyAll()
示例7: test_verify_delete_when_no_delete
def test_verify_delete_when_no_delete(self):
exist = self.mox.CreateMockAnything()
exist.delete = None
exist.uuid = IMAGE_UUID_1
exist.deleted_at = None
audit_period_ending = decimal.Decimal("1.2")
exist.audit_period_ending = audit_period_ending
results = self.mox.CreateMockAnything()
models.ImageDeletes.find(IMAGE_UUID_1, dt.dt_from_decimal(audit_period_ending)).AndReturn(results)
results.count().AndReturn(0)
self.mox.ReplayAll()
glance_verifier._verify_for_delete(exist)
self.mox.VerifyAll()
示例8: test_verify_delete_when_late_delete
def test_verify_delete_when_late_delete(self):
exist = self.mox.CreateMockAnything()
exist.uuid = IMAGE_UUID_1
exist.delete = None
exist.deleted_at = decimal.Decimal("5.1")
results = self.mox.CreateMockAnything()
models.ImageDeletes.find(uuid=IMAGE_UUID_1).AndReturn(results)
results.count().AndReturn(1)
delete = self.mox.CreateMockAnything()
delete.deleted_at = decimal.Decimal("5.1")
results.__getitem__(0).AndReturn(delete)
self.mox.ReplayAll()
glance_verifier._verify_for_delete(exist)
self.mox.VerifyAll()
示例9: test_verify_for_delete_size_mismatch
def test_verify_for_delete_size_mismatch(self):
exist = self.mox.CreateMockAnything()
exist.delete = self.mox.CreateMockAnything()
exist.launched_at = decimal.Decimal('1.1')
exist.deleted_at = decimal.Decimal('5.1')
exist.delete.launched_at = decimal.Decimal('1.1')
exist.delete.deleted_at = decimal.Decimal('6.1')
self.mox.ReplayAll()
try:
glance_verifier._verify_for_delete(exist)
self.fail()
except FieldMismatch, fm:
self.assertEqual(fm.field_name, 'deleted_at')
self.assertEqual(fm.expected, decimal.Decimal('5.1'))
self.assertEqual(fm.actual, decimal.Decimal('6.1'))
示例10: 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)
示例11: test_verify_delete_deleted_at_mismatch
def test_verify_delete_deleted_at_mismatch(self):
utils.mock_datetime_utcnow(self.mox, "2014-01-02 03:04:05")
exist = self.mox.CreateMockAnything()
exist.uuid = IMAGE_UUID_1
exist.delete = self.mox.CreateMockAnything()
exist.deleted_at = DELETED_AT_1
exist.delete.deleted_at = DELETED_AT_2
self.mox.ReplayAll()
with self.assertRaises(FieldMismatch) as fm:
glance_verifier._verify_for_delete(exist)
exception = fm.exception
entity_1 = {"name": "exists", "value": DELETED_AT_1}
entity_2 = {"name": "deletes", "value": DELETED_AT_2}
self.assertEqual(exception.field_name, "deleted_at")
self.assertEqual(exception.entity_1, entity_1)
self.assertEqual(exception.entity_2, entity_2)
self.mox.VerifyAll()
示例12: test_verify_delete_found_delete_when_exist_deleted_at_is_none
def test_verify_delete_found_delete_when_exist_deleted_at_is_none(self):
exist = self.mox.CreateMockAnything()
exist.delete = None
exist.uuid = IMAGE_UUID_1
audit_period_ending = decimal.Decimal("1.3")
exist.deleted_at = None
exist.audit_period_ending = audit_period_ending
results = self.mox.CreateMockAnything()
models.ImageDeletes.find(IMAGE_UUID_1, dt.dt_from_decimal(audit_period_ending)).AndReturn(results)
results.count().AndReturn(1)
self.mox.ReplayAll()
with self.assertRaises(VerificationException) as ve:
glance_verifier._verify_for_delete(exist)
exception = ve.exception
self.assertEqual(exception.reason, "Found ImageDeletes for non-delete exist")
self.mox.VerifyAll()