예제 #1
0
 def test_group_validation_errors(self):
     fake_resp_body = mock.MagicMock(name='response_body')
     fake_resp_body.body = json.dumps(
         {
             'request': {
                 'id': 'fake_id',
                 'url': '/fake',
                 'method': 'GET',
                 'timestamp': '2016-12-28T22:36:36.324Z',
             },
             'response': {
                 'errors': [
                     {'message': 'Cant create spot requests.',
                      'code': 'GENERAL_ERROR'},
                     {'message': 'AMI ami-16fc4976 with an...',
                      'code': 'UnsupportedOperation'},
                 ]
             },
         }
     )
     source_exc = httpclient.HTTPError(
         400, '400 Bad Request', fake_resp_body)
     fake_exc = spotinst.SpotinstException(source_exc)
     self.assertEquals(
         ('Spotinst Request ID (fake_id) GET /fake: GENERAL_ERROR: Cant '
          'create spot requests., UnsupportedOperation: AMI ami-16fc4976 '
          'with an...'),
         str(fake_exc))
예제 #2
0
 def test_unknown_error_body(self):
     fake_resp_body = mock.MagicMock(name='response_body')
     fake_resp_body.body = json.dumps({
         'request': {
             'id': 'fake_id',
             'url': '/fake',
             'method': 'GET',
             'timestamp': '2016-12-28T22:36:36.324Z',
         },
         'response': {
             'something': 'else'
         },
     })
     source_exc = httpclient.HTTPError(400, '400 Bad Request',
                                       fake_resp_body)
     fake_exc = spotinst.SpotinstException(source_exc)
     self.assertEqual(('Spotinst Request ID (fake_id) GET /fake: '
                       '{\'something\': \'else\'}'), str(fake_exc))
예제 #3
0
 def test_invalid_auth_response(self):
     fake_resp_body = mock.MagicMock(name='response_body')
     fake_resp_body.body = json.dumps({
         'request': {
             'id': 'fake_id',
             'url': '/fake',
             'method': 'GET',
             'timestamp': '2016-12-28T22:36:36.324Z',
         },
         'response': {
             'error': 'invalid auth',
             'error_id': 'NOAUTH'
         },
     })
     source_exc = httpclient.HTTPError(400, '400 Bad Request',
                                       fake_resp_body)
     fake_exc = spotinst.SpotinstException(source_exc)
     self.assertEqual(
         'Spotinst Request ID (fake_id) GET /fake: invalid auth',
         str(fake_exc))
예제 #4
0
 def test_no_json_in_body(self):
     fake_body = '400 Bad Mmmkay'
     exc = spotinst.SpotinstException(fake_body)
     self.assertEquals(
         'Unknown error: 400 Bad Mmmkay',
         str(exc))