'Tests the online data migration used to cleanup failed Mitaka-era
build requests that have no instance_uuid set.'

def test_delete_build_requests_with_no_instance_uuid(self):

    for x in range(2):
        db_req = self._get_mitaka_db_build_request_no_instance_uuid()
        self.build_req_obj._create_in_db(self.context, db_req)
    ctxt = context.get_admin_context()
    (total, deleted) = build_request.delete_build_requests_with_no_instance_uuid(ctxt, 0)
    self.assertEqual(0, total)
    self.assertEqual(0, deleted)
    (total, deleted) = build_request.delete_build_requests_with_no_instance_uuid(ctxt, 1)
    self.assertEqual(1, total)
    self.assertEqual(1, deleted)
    (total, deleted) = build_request.delete_build_requests_with_no_instance_uuid(ctxt, 50)
    self.assertEqual(1, total)
    self.assertEqual(1, deleted)
    (total, deleted) = build_request.delete_build_requests_with_no_instance_uuid(ctxt, 50)
    self.assertEqual(0, total)
    self.assertEqual(0, deleted)
