import json
import unittest

from alerta.app import create_app, db


class ApiResponseTestCase(unittest.TestCase):

    def setUp(self):
        test_config = {
            'TESTING': True,
            'BASE_URL': 'https://api.alerta.dev:9898/_'
        }
        self.app = create_app(test_config)
        self.client = self.app.test_client()

        self.prod_alert = {
            'id': 'custom-alert-id',
            'resource': 'node404',
            'event': 'node_down',
            'environment': 'Production',
            'severity': 'major',
            'correlate': ['node_down', 'node_marginal', 'node_up'],
            'service': ['Core', 'Web', 'Network'],
            'group': 'Network',
            'tags': ['level=20', 'switch:off']
        }

    def tearDown(self):
        db.destroy()

    def test_response_href(self):

        # create alert
        response = self.client.post('/alert', json=self.prod_alert)
        self.assertEqual(response.status_code, 201)
        data = json.loads(response.data.decode('utf-8'))
        self.assertEqual(data['alert']['href'], 'https://api.alerta.dev:9898/_/alert/custom-alert-id')

@@ -797,24 +797,433 @@
 .destroy()%0A%0A
+    def test_response_custom_id(self):%0A%0A        # create alert%0A        response = self.client.post('/alert', json=self.prod_alert)%0A        self.assertEqual(response.status_code, 201)%0A        data = json.loads(response.data.decode('utf-8'))%0A        self.assertEqual(data%5B'alert'%5D%5B'id'%5D, 'custom-alert-id')%0A        self.assertEqual(data%5B'id'%5D, 'custom-alert-id')%0A        self.assertEqual(data%5B'status'%5D, 'ok')%0A%0A
     def test
@@ -1532,24 +1532,71 @@
 alert/custom-alert-id')%0A
+        self.assertEqual(data%5B'status'%5D, 'ok')%0A

Add test for custom id in response