Beispiel #1
0
 def setUp(self):
     op = sc_messages.QuotaOperation(
         consumerId=_TEST_CONSUMER_ID,
         methodName=_TEST_OP_NAME
     )
     self.test_quota_request = sc_messages.AllocateQuotaRequest(allocateOperation=op)
     self.test_op = op
Beispiel #2
0
def _make_test_request(service_name, operation_id=None, importance=None):
    if importance is None:
        importance = sc_messages.Operation.ImportanceValueValuesEnum.LOW
    op = sc_messages.QuotaOperation(
        consumerId=_TEST_CONSUMER_ID,
        methodName=_TEST_OP_NAME,
        operationId=operation_id,
    )
    quota_request = sc_messages.AllocateQuotaRequest(allocateOperation=op)
    return sc_messages.ServicecontrolServicesAllocateQuotaRequest(
        serviceName=service_name,
        allocateQuotaRequest=quota_request)
Beispiel #3
0
 def test_should_fail_if_operation_has_no_consumer_id(self):
     op = sc_messages.QuotaOperation(methodName=_TEST_OP_NAME)
     testf = lambda: quota_request.sign(
         sc_messages.AllocateQuotaRequest(allocateOperation=op))
     expect(testf).to(raise_error(ValueError))
Beispiel #4
0
 def test_should_fail_if_operation_has_no_method_name(self):
     op = sc_messages.QuotaOperation(consumerId=_TEST_CONSUMER_ID)
     testf = lambda: quota_request.sign(
         sc_messages.AllocateQuotaRequest(allocateOperation=op))
     expect(testf).to(raise_error(ValueError))
Beispiel #5
0
 def test_should_fail_if_operation_is_not_set(self):
     testf = lambda: quota_request.sign(sc_messages.AllocateQuotaRequest())
     expect(testf).to(raise_error(ValueError))
Beispiel #6
0
 def test_should_fail_if_operation_is_missing(self):
     req = sc_messages.ServicecontrolServicesAllocateQuotaRequest(
         serviceName=self.SERVICE_NAME,
         allocateQuotaRequest=sc_messages.AllocateQuotaRequest())
     testf = lambda: self.agg.allocate_quota(req)
     expect(testf).to(raise_error(ValueError))