Ejemplo n.º 1
0
 def test_should_change_signature_when_labels_are_added(self):
     without_labels = check_request.sign(self.test_check_request)
     self.test_op.labels = encoding.PyValueToMessage(
         sc_messages.Operation.LabelsValue, {
             u'key1': u'value1',
             u'key2': u'value2'})
     with_labels = check_request.sign(self.test_check_request)
     expect(with_labels).not_to(equal(without_labels))
 def test_should_change_signature_when_labels_are_added(self):
     without_labels = check_request.sign(self.test_check_request)
     self.test_op.labels = encoding.PyValueToMessage(
         messages.Operation.LabelsValue, {
             u'key1': u'value1',
             u'key2': u'value2'})
     with_labels = check_request.sign(self.test_check_request)
     expect(with_labels).not_to(equal(without_labels))
Ejemplo n.º 3
0
 def test_should_change_signature_when_metric_values_are_added(self):
     without_mvs = check_request.sign(self.test_check_request)
     self.test_op.metricValueSets = [
         messages.MetricValueSet(metricName=u'a_float',
                                 metricValues=[
                                     metric_value.create(
                                         labels={
                                             u'key1': u'value1',
                                             u'key2': u'value2'
                                         },
                                         doubleValue=1.1,
                                     ),
                                 ])
     ]
     with_mvs = check_request.sign(self.test_check_request)
     expect(with_mvs).not_to(equal(without_mvs))
 def test_should_change_signature_when_metric_values_are_added(self):
     without_mvs = check_request.sign(self.test_check_request)
     self.test_op.metricValueSets = [
         messages.MetricValueSet(
             metricName=u'a_float',
             metricValues=[
                 metric_value.create(
                     labels={
                         u'key1': u'value1',
                         u'key2': u'value2'},
                     doubleValue=1.1,
                 ),
             ]
         )
     ]
     with_mvs = check_request.sign(self.test_check_request)
     expect(with_mvs).not_to(equal(without_mvs))
Ejemplo n.º 5
0
 def test_should_change_signature_quota_properties_are_specified(self):
     without_qprops = check_request.sign(self.test_check_request)
     self.test_op.quotaProperties = messages.QuotaProperties()
     with_qprops = check_request.sign(self.test_check_request)
     expect(with_qprops).not_to(equal(without_qprops))
Ejemplo n.º 6
0
 def test_should_sign_a_valid_check_request(self):
     check_request.sign(self.test_check_request)
Ejemplo n.º 7
0
 def test_should_fail_if_operation_has_no_consumer_id(self):
     op = messages.Operation(operationName=_TEST_OP_NAME)
     testf = lambda: check_request.sign(messages.CheckRequest(operation=op))
     expect(testf).to(raise_error(ValueError))
Ejemplo n.º 8
0
 def test_should_fail_if_operation_has_no_operation_name(self):
     op = messages.Operation(consumerId=_TEST_CONSUMER_ID)
     testf = lambda: check_request.sign(messages.CheckRequest(operation=op))
     expect(testf).to(raise_error(ValueError))
Ejemplo n.º 9
0
 def test_should_fail_on_invalid_input(self):
     testf = lambda: check_request.sign(None)
     expect(testf).to(raise_error(ValueError))
     testf = lambda: check_request.sign(object())
     expect(testf).to(raise_error(ValueError))
Ejemplo n.º 10
0
 def test_should_fail_if_operation_is_not_set(self):
     testf = lambda: check_request.sign(messages.CheckRequest())
     expect(testf).to(raise_error(ValueError))
 def test_should_change_signature_quota_properties_are_specified(self):
     without_qprops = check_request.sign(self.test_check_request)
     self.test_op.quotaProperties = messages.QuotaProperties()
     with_qprops = check_request.sign(self.test_check_request)
     expect(with_qprops).not_to(equal(without_qprops))
 def test_should_sign_a_valid_check_request(self):
     check_request.sign(self.test_check_request)
 def test_should_fail_if_operation_has_no_consumer_id(self):
     op = messages.Operation(operationName=_TEST_OP_NAME)
     testf = lambda: check_request.sign(messages.CheckRequest(operation=op))
     expect(testf).to(raise_error(ValueError))
 def test_should_fail_if_operation_has_no_operation_name(self):
     op = messages.Operation(consumerId=_TEST_CONSUMER_ID)
     testf = lambda: check_request.sign(messages.CheckRequest(operation=op))
     expect(testf).to(raise_error(ValueError))
 def test_should_fail_on_invalid_input(self):
     testf = lambda: check_request.sign(None)
     expect(testf).to(raise_error(ValueError))
     testf = lambda: check_request.sign(object())
     expect(testf).to(raise_error(ValueError))
 def test_should_fail_if_operation_is_not_set(self):
     testf = lambda: check_request.sign(messages.CheckRequest())
     expect(testf).to(raise_error(ValueError))