Esempio n. 1
0
 def test_Cachet_get_fail_post_skip(self):
     """
     Unsuccessful GET request, skips incident POST as a result
     """
     responses.add(responses.GET, "http://status.company.com/api/v1/components", status=400)
     status_code = plugins.notify_cache(self.obj, self.message_template, CONSUL_CACHET)
     self.assertEqual(None, status_code)
Esempio n. 2
0
    def test_Cachet_get_no_intersecting_tag_post_skipped(self):
        """
        Successfully GET components
        However, because the retrieved components do not match any of the provided tags
        A ValueError is encountered and we do not POST incident
        """
        get_data = {
            'data': [
                {
                    "id": 2,
                    "name":
                    "notRedis",  # we change the name in this test to something we know does not match
                },
                {
                    "id": 4,
                    "name": "mysql",
                }
            ]
        }

        responses.add(responses.GET,
                      "http://status.company.com/api/v1/components",
                      json=get_data,
                      status=200)
        status_code = plugins.notify_cache(self.obj, self.message_template,
                                           CONSUL_CACHET)
        self.assertEqual(None, status_code)
Esempio n. 3
0
    def test_Cachet_get_post(self):
        """
        Successfully GET components, identifies intersecting tag, and POSTs incident to Cachet
        """
        get_data = {
            'data': [{
                "id": 2,
                "name": "Redis",
            }, {
                "id": 4,
                "name": "mysql",
            }]
        }

        responses.add(responses.GET,
                      "http://status.company.com/api/v1/components",
                      json=get_data,
                      status=200)
        responses.add(responses.POST,
                      "http://status.company.com/api/v1/incidents",
                      json=True,
                      status=200)
        status_code = plugins.notify_cache(self.obj, self.message_template,
                                           CONSUL_CACHET)
        self.assertEqual(200, status_code)
Esempio n. 4
0
 def test_Cachet_get_no_data_post_skipped(self):
     """
     Successfully GET response but no Component data, does not find tag intersection, does not POST incident
     """
     get_data = {"data": []}
     responses.add(responses.GET, "http://status.company.com/api/v1/components", json=get_data, status=200)
     status_code = plugins.notify_cache(self.obj, self.message_template, CONSUL_CACHET)
     self.assertEqual(None, status_code)
Esempio n. 5
0
 def test_Cachet_no_site_url(self):
     """
     No POST due to missing site url
     """
     consul_cachet_sub_api_token = CONSUL_CACHET
     consul_cachet_sub_api_token["site_url"] = None
     status_code = plugins.notify_cache(self.obj, self.message_template, consul_cachet_sub_api_token)
     self.assertEqual(None, status_code)
Esempio n. 6
0
 def test_Cachet_no_site_url(self):
     """
     No POST due to missing site url
     """
     consul_cachet_sub_api_token = CONSUL_CACHET
     consul_cachet_sub_api_token['site_url'] = None
     status_code = plugins.notify_cache(self.obj, self.message_template,
                                        consul_cachet_sub_api_token)
     self.assertEqual(None, status_code)
Esempio n. 7
0
 def test_Cachet_get_fail_post_skip(self):
     """
     Unsuccessful GET request, skips incident POST as a result
     """
     responses.add(responses.GET,
                   "http://status.company.com/api/v1/components",
                   status=400)
     status_code = plugins.notify_cache(self.obj, self.message_template,
                                        CONSUL_CACHET)
     self.assertEqual(None, status_code)
Esempio n. 8
0
    def test_Cachet_get_post_fail(self):
        """
        Successfully GET components, identifies intersecting tag, but POST fails
        """
        get_data = {"data": [{"id": 2, "name": "Redis"}, {"id": 4, "name": "mysql"}]}

        responses.add(responses.GET, "http://status.company.com/api/v1/components", json=get_data, status=200)
        responses.add(responses.POST, "http://status.company.com/api/v1/incidents", status=400)
        status_code = plugins.notify_cache(self.obj, self.message_template, CONSUL_CACHET)
        self.assertEqual(None, status_code)
Esempio n. 9
0
 def test_Cachet_get_no_data_post_skipped(self):
     """
     Successfully GET response but no Component data, does not find tag intersection, does not POST incident
     """
     get_data = {'data': []}
     responses.add(responses.GET,
                   "http://status.company.com/api/v1/components",
                   json=get_data,
                   status=200)
     status_code = plugins.notify_cache(self.obj, self.message_template,
                                        CONSUL_CACHET)
     self.assertEqual(None, status_code)
Esempio n. 10
0
    def test_Cachet_get_no_intersecting_tag_post_skipped(self):
        """
        Successfully GET components
        However, because the retrieved components do not match any of the provided tags
        A ValueError is encountered and we do not POST incident
        """
        get_data = {
            "data": [
                {"id": 2, "name": "notRedis"},  # we change the name in this test to something we know does not match
                {"id": 4, "name": "mysql"},
            ]
        }

        responses.add(responses.GET, "http://status.company.com/api/v1/components", json=get_data, status=200)
        status_code = plugins.notify_cache(self.obj, self.message_template, CONSUL_CACHET)
        self.assertEqual(None, status_code)