示例#1
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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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")
 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)
示例#16
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)
 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")
示例#18
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)
示例#19
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)
 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")
示例#21
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)
示例#22
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)
 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")
 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")
 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")