Example #1
0
 def testCWNamespaceHandlerNamespaceAWSInvalidType(self):
   """
   Test for Get '/_metrics/cloudwatch/AWS/<invalid_namespace>'
   response is validated for appropriate headers, body and status
   response is validated for error message
   """
   response = self.app.get('/AWS/foo', status="*", headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #2
0
 def testCWNamespaceHandlerNamespaceAWSInvalidType(self):
     """
 Test for Get '/_metrics/cloudwatch/AWS/<invalid_namespace>'
 response is validated for appropriate headers, body and status
 response is validated for error message
 """
     response = self.app.get('/AWS/foo', status="*", headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #3
0
 def testDeleteModelInvalid(self, getMetricMock, _engineMock):
     getMetricMock.side_effect = ObjectNotFoundError("Test")
     response = self.app.delete("/12232-jn939",
                                headers=self.headers,
                                status="*")
     assertions.assertNotFound(self, response)
     self.assertEqual(
         "ObjectNotFoundError Metric not found:"
         " Metric ID: 12232-jn939", response.body)
Example #4
0
 def testGETRegionInvalid(self):
   """
   Test for Get '/_metrics/cloudwatch/regions/<invalid-region-name>'
   response is validated for appropriate headers, body and status
   response is validated against expected error message
   """
   response = self.app.get('/regions/fake-region', status="*",
    headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Region 'fake-region' was not found", response.body)
Example #5
0
 def testGETRegionInvalid(self):
     """
 Test for Get '/_metrics/cloudwatch/regions/<invalid-region-name>'
 response is validated for appropriate headers, body and status
 response is validated against expected error message
 """
     response = self.app.get('/regions/fake-region',
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Region 'fake-region' was not found", response.body)
Example #6
0
 def testDeleteMultipleWithInvalidInstanceId(self):
   """
   Test for post '/_instances'
   response is validated for appropriate headers, body and status
   invoke delete with invalid Instance id
   """
   params = ["abcd1234"]
   response = self.app.delete("", params=app_utils.jsonEncode(params),
     headers=self.headers, status="*")
   assertions.assertNotFound(self, response)
   self.assertIn("Not able to delete", response.body)
Example #7
0
 def testGetListRegionMetricsEmptyResponse(self, adapterMock):
   """
   Test for Get '/_metrics/cloudwatch/regions/<invalid-region-name>'
   response is validated for appropriate headers, body and status
   response is validated against expected error message
   """
   adapterMock.return_value.describeRegions.return_value = self.regions
   response = self.app.get('/regions/fake-region', status="*",
    headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Region 'fake-region' was not found", response.body)
Example #8
0
 def testGETListInstancesForInvalidNamespaceWithInstanceId(self):
   """
   Test for Get
   '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/<InstancdId>'
   with invalid namespace
   response is validated for appropriate headers, body and status
   and expected error message
   """
   response = self.app.get("/us-west-2/AWS/foo/instances/%s"
     % VALID_EC2_INSTANCE["InstanceId"], status="*", headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #9
0
 def testGetListRegionMetricsEmptyResponse(self, adapterMock):
     """
 Test for Get '/_metrics/cloudwatch/regions/<invalid-region-name>'
 response is validated for appropriate headers, body and status
 response is validated against expected error message
 """
     adapterMock.return_value.describeRegions.return_value = self.regions
     response = self.app.get('/regions/fake-region',
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Region 'fake-region' was not found", response.body)
Example #10
0
 def testGETMetricsInvalidRegion(self):
   """
   Test for
   Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
   with invalid region
   response is validated for appropriate headers, body and status
   and reponse  is validated for error message
   """
   response = self.app.get("/fake-region/AWS/EC2/CPUUtilization", status="*",
    headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Region 'fake-region' was not found", response.body)
Example #11
0
 def testGETListInstancesForInvalidNamespace(self):
   """
   Test for
   Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
   with invalid namespace
   response is validated for appropriate headers, body and status
   and reponse  is validated for error message
   """
   response = self.app.get("/us-west-2/AWS/foo/CPUUtilization", status="*",
    headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #12
0
 def testGETListInstancesForInvalidMetrcName(self):
   """
   Test for
   Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
   with invalid metric
   response is validated for appropriate headers, body and status
   and reponse  is validated for error message
   """
   response = self.app.get("/us-west-2/AWS/EC2/GroupTotalInstances",
     status="*", headers=self.headers)
   assertions.assertNotFound(self, response)
   self.assertIn("Metric 'GroupTotalInstances' was not found", response.body)
Example #13
0
 def testGetNamespaceAWSInvalidType(self, adapterMock):
   """
   Test for Get '/_metrics/cloudwatch/AWS/<invalid_namespace>'
   response is validated for appropriate headers, body and status
   response is validated for error message
   """
   adapterMock.return_value.describeRegions.return_value = self.regions
   adapterMock.return_value.describeSupportedMetrics.return_value = (
     self.resources)
   response = self.app.get("/AWS/foo", headers=self.headers, status="*")
   assertions.assertNotFound(self, response)
   self.assertEqual("Namespace 'AWS/foo' was not found", response.body)
Example #14
0
 def testGetNamespaceAWSInvalidType(self, adapterMock):
     """
 Test for Get '/_metrics/cloudwatch/AWS/<invalid_namespace>'
 response is validated for appropriate headers, body and status
 response is validated for error message
 """
     adapterMock.return_value.describeRegions.return_value = self.regions
     adapterMock.return_value.describeSupportedMetrics.return_value = (
         self.resources)
     response = self.app.get("/AWS/foo", headers=self.headers, status="*")
     assertions.assertNotFound(self, response)
     self.assertEqual("Namespace 'AWS/foo' was not found", response.body)
Example #15
0
 def testGETListInstancesForInvalidNamespace(self):
     """
 Test for
 Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
 with invalid namespace
 response is validated for appropriate headers, body and status
 and reponse  is validated for error message
 """
     response = self.app.get("/us-west-2/AWS/foo/CPUUtilization",
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #16
0
 def testGETListInstancesForInvalidMetric(self):
     """
 Test for
 Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName/'
 with invalid metric
 response is validated for appropriate headers, body and status
 and reponse  is validated for error message
 """
     response = self.app.get("/us-west-2/AWS/EC2/fake-metric",
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Metric 'fake-metric' was not found", response.body)
Example #17
0
 def testGETMetricsInvalidRegion(self):
     """
 Test for
 Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
 with invalid region
 response is validated for appropriate headers, body and status
 and reponse  is validated for error message
 """
     response = self.app.get("/fake-region/AWS/EC2/CPUUtilization",
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Region 'fake-region' was not found", response.body)
Example #18
0
 def testDeleteMultipleWithInvalidInstanceId(self):
     """
 Test for post '/_instances'
 response is validated for appropriate headers, body and status
 invoke delete with invalid Instance id
 """
     params = ["abcd1234"]
     response = self.app.delete("",
                                params=app_utils.jsonEncode(params),
                                headers=self.headers,
                                status="*")
     assertions.assertNotFound(self, response)
     self.assertIn("Not able to delete", response.body)
Example #19
0
 def testGetInstanceWithInvalidNamespace(self, adapterMock):
   """
   Test for Get
   '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/<InstancdId>'
   with invalid InstancceId
   response is validated for appropriate headers, body and status
   """
   adapterMock.return_value.describeRegions.return_value = self.regions
   adapterMock.return_value.describeSupportedMetrics.return_value = (
     self.resources)
   response = self.app.get("/us-east-1/AWS/foo/instances/i-832311",
     headers=self.headers, status="*")
   assertions.assertNotFound(self, response)
   self.assertEqual(response.body, "Namespace 'AWS/foo' was not found")
Example #20
0
 def testGETListInstancesForInvalidNamespaceWithInstanceId(self):
     """
 Test for Get
 '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/<InstancdId>'
 with invalid namespace
 response is validated for appropriate headers, body and status
 and expected error message
 """
     response = self.app.get("/us-west-2/AWS/foo/instances/%s" %
                             VALID_EC2_INSTANCE["InstanceId"],
                             status="*",
                             headers=self.headers)
     assertions.assertNotFound(self, response)
     self.assertIn("Namespace 'AWS/foo' was not found", response.body)
Example #21
0
 def testGetInstanceWithInvalidNamespace(self, adapterMock):
     """
 Test for Get
 '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/<InstancdId>'
 with invalid InstancceId
 response is validated for appropriate headers, body and status
 """
     adapterMock.return_value.describeRegions.return_value = self.regions
     adapterMock.return_value.describeSupportedMetrics.return_value = (
         self.resources)
     response = self.app.get("/us-east-1/AWS/foo/instances/i-832311",
                             headers=self.headers,
                             status="*")
     assertions.assertNotFound(self, response)
     self.assertEqual(response.body, "Namespace 'AWS/foo' was not found")
Example #22
0
 def testGetInstanceWithInvalidRegion(self, adapterMock):
   """
   Test for
   Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/'
   with invalid region
   response is validated for appropriate headers, body and status
   and error message
   """
   adapterMock.return_value.describeRegions.return_value = self.regions
   adapterMock.return_value.describeSupportedMetrics.return_value = (
     self.resources)
   response = self.app.get("/fake-region/AWS/EC2/instances/i-832311",
     headers=self.headers, status="*")
   assertions.assertNotFound(self, response)
   self.assertEqual(response.body, "Region 'fake-region' was not found")
Example #23
0
 def testGetMetricInvalidNamespace(self, adapterMock):
   """
   Test for
   Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
   with invalid namespace
   response is validated for appropriate headers, body and status
   and reponse  is validated for error message
   """
   adapterMock.return_value.describeRegions.return_value = self.regions
   adapterMock.return_value.describeSupportedMetrics.return_value = (
     self.resources)
   response = self.app.get("/us-east-1/AWS/foo/CPUUtilization",
      headers=self.headers, status="*")
   assertions.assertNotFound(self, response)
   self.assertEqual(response.body, "Namespace 'AWS/foo' was not found")
Example #24
0
 def testGetInstanceWithInvalidRegion(self, adapterMock):
     """
 Test for
 Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/instances/'
 with invalid region
 response is validated for appropriate headers, body and status
 and error message
 """
     adapterMock.return_value.describeRegions.return_value = self.regions
     adapterMock.return_value.describeSupportedMetrics.return_value = (
         self.resources)
     response = self.app.get("/fake-region/AWS/EC2/instances/i-832311",
                             headers=self.headers,
                             status="*")
     assertions.assertNotFound(self, response)
     self.assertEqual(response.body, "Region 'fake-region' was not found")
Example #25
0
 def testGetMetricInvalidNamespace(self, adapterMock):
     """
 Test for
 Get '/_metrics/cloudwatch/<region-name>/AWS/<namespace>/metricName'
 with invalid namespace
 response is validated for appropriate headers, body and status
 and reponse  is validated for error message
 """
     adapterMock.return_value.describeRegions.return_value = self.regions
     adapterMock.return_value.describeSupportedMetrics.return_value = (
         self.resources)
     response = self.app.get("/us-east-1/AWS/foo/CPUUtilization",
                             headers=self.headers,
                             status="*")
     assertions.assertNotFound(self, response)
     self.assertEqual(response.body, "Namespace 'AWS/foo' was not found")