Ejemplo n.º 1
0
    def test_update_group_config_fail_500(self):
        """
        If the update fails for some strange reason, a 500 is returned
        """
        self.mock_group.update_config.return_value = defer.fail(
            DummyException())

        request_body = {
            'name': 'blah',
            'cooldown': 60,
            'minEntities': 0,
            'maxEntities': 25,
            'metadata': {}
        }
        expected_config = {
            'name': 'blah',
            'cooldown': 60,
            'minEntities': 0,
            'maxEntities': 25,
            'metadata': {}
        }

        response_body = self.assert_status_code(500,
                                                method="PUT",
                                                body=json.dumps(request_body))
        resp = json.loads(response_body)

        self.mock_store.get_scaling_group.assert_called_once_with(
            mock.ANY, '11111', '1')
        self.mock_group.update_config.assert_called_once_with(expected_config)
        self.assertEqual(resp['type'], 'InternalError')
        self.flushLoggedErrors(DummyException)
Ejemplo n.º 2
0
 def test_list_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.list_policies.return_value = defer.fail(error)
     self.assert_status_code(500)
     self.flushLoggedErrors()
Ejemplo n.º 3
0
 def test_delete_webhook_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.delete_webhook.return_value = defer.fail(error)
     self.assert_status_code(500, None, 'DELETE')
     self.mock_group.delete_webhook.assert_called_once_with(
         self.policy_id, self.webhook_id)
     self.flushLoggedErrors(DummyException)
Ejemplo n.º 4
0
 def test_list_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.list_webhooks.return_value = defer.fail(error)
     self.assert_status_code(500)
     self.mock_group.list_webhooks.assert_called_once_with(self.policy_id,
                                                           limit=100)
     self.flushLoggedErrors(DummyException)
Ejemplo n.º 5
0
 def test_update_policy_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.update_policy.return_value = defer.fail(error)
     self.assert_status_code(500,
                             method="PUT",
                             body=json.dumps(policy_examples()[1]))
     self.flushLoggedErrors()
Ejemplo n.º 6
0
    def test_get_group_config_500(self):
        """
        Unknown errors return a 500 as a response http code.
        """
        self.mock_group.view_config.return_value = defer.fail(DummyException())
        response_body = self.assert_status_code(500)
        resp = json.loads(response_body)

        self.mock_store.get_scaling_group.assert_called_once_with(
            mock.ANY, '11111', '1')
        self.mock_group.view_config.assert_called_once_with()
        self.assertEqual(resp['type'], 'InternalError')
        self.flushLoggedErrors(DummyException)
Ejemplo n.º 7
0
 def test_create_webhooks_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.create_webhooks.return_value = defer.fail(error)
     self.assert_status_code(500, None, 'POST', json.dumps([{
         'name': 'one'
     }]))
     self.mock_group.create_webhooks.assert_called_once_with(
         self.policy_id, [{
             'name': 'one'
         }])
     self.flushLoggedErrors(DummyException)
Ejemplo n.º 8
0
 def test_create_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     request_body = {
         'groupConfiguration': config_examples()[0],
         'launchConfiguration': launch_examples()[0]
     }
     self.mock_store.create_scaling_group.return_value = defer.fail(error)
     self.assert_status_code(500,
                             method="POST",
                             body=json.dumps(request_body))
     self.flushLoggedErrors()
Ejemplo n.º 9
0
 def test_update_webhook_unknown_error_is_500(self):
     """
     If an unexpected exception is raised, endpoint returns a 500.
     """
     error = DummyException('what')
     self.mock_group.update_webhook.return_value = defer.fail(error)
     self.assert_status_code(500, None, 'PUT',
                             json.dumps({
                                 'name': 'one',
                                 'metadata': {}
                             }))
     self.mock_group.update_webhook.assert_called_once_with(
         self.policy_id, self.webhook_id, {
             'name': 'one',
             'metadata': {}
         })
     self.flushLoggedErrors(DummyException)
Ejemplo n.º 10
0
    def test_update_launch_config_fail_500(self):
        """
        If the update fails for some strange reason, a 500 is returned
        """
        self.mock_group.update_launch_config.return_value = defer.fail(
            DummyException())

        response_body = self.assert_status_code(500,
                                                method="PUT",
                                                body=json.dumps(
                                                    launch_examples()[0]))
        resp = json.loads(response_body)

        self.mock_store.get_scaling_group.assert_called_once_with(
            mock.ANY, '11111', '1')
        self.mock_group.update_launch_config.assert_called_once_with(
            launch_examples()[0])
        self.assertEqual(resp['type'], 'InternalError')
        self.flushLoggedErrors(DummyException)