예제 #1
0
 def testPutMethodWithNoData(self):
   """
   Test making a PUT call with no data.
   """
   response = self.app.put("/", status="*", headers=self.headers)
   self.assertIn("Metric data is missing", response.body)
   assertions.assertBadRequest(self, response)
예제 #2
0
 def testPostWithoutInstanceId(self):
   """
   Test for post '/_instances/region/namespace/instanceId' without instanceId
   response is validated for appropriate headers, body and status
   This invokes post call with without instanceId
   """
   response = self.app.post("/us-west-2/AWS/EC2/",
    headers=self.headers, status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("Invalid request", response.body)
예제 #3
0
  def testCreateModelWithInvalidMetricArg(self):
    """
      Test for the invalid metric field in json.
    """
    data = utils.jsonEncode(self.modelsTestData["create_invalid_metric_data"])
    response = self.app.put("/", data, status="*", headers=self.headers)
    assertions.assertBadRequest(self, response, "json")

    response = self.app.get("/", headers=self.headers)
    self.assertFalse(json.loads(response.body),
                     "Model actually created with invalid metric")
예제 #4
0
 def testDeleteMultipleinstancesWithInvalidData(self):
   """
   Test for post '/_instances'
   response is validated for appropriate headers, body and status
   invoke delete with invalid Instance id
   """
   params = []
   response = self.app.delete("", params=params, headers=self.headers,
     status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("Invalid request", response.body)
예제 #5
0
 def testPostMultipleWithInstanceToIncorrectRegion(self):
   """
   Test for post '/_instances'
   response is validated for appropriate headers, body and status
   invoke post with valid instance id to incorrect region
   """
   params = [VALID_EC2_INSTANCES["jenkins-master"]]
   response = self.app.post("/us-east-1/AWS/EC2",
     params=app_utils.jsonEncode(params), headers=self.headers, status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("InvalidArgumentsError", response.body)
예제 #6
0
 def testPostMultipleWithNonJsonData(self):
   """
   Test for '/_instances'
   response is validated for appropriate headers, body and status
   Invoke post with non-json data
   """
   params = []
   response = self.app.post("/us-west-2/AWS/EC2",
     params=params, headers=self.headers, status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("Invalid request", response.body)
예제 #7
0
 def testPostMultipleWithEmptyData(self):
   """
   Test for post '/_instances'
   response is validated for appropriate headers, body and status
   Invoke post with empty data
   """
   params = []
   response = self.app.post("/us-west-2/AWS/EC2",
     params=app_utils.jsonEncode(params), headers=self.headers, status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("InvalidArgumentsError", response.body)
예제 #8
0
 def testPostWithInvalidNamespace(self):
   """
   Test for post '/_instances/region/namespace/instanceId'
   response is validated for appropriate headers, body and status
   Invoke Api call with namespace that does not exists
   """
   region = "us-west-2"
   namespace = "foo"
   instanceId = VALID_EC2_INSTANCES["jenkins-master"]["instanceId"]
   response = self.app.post("/%s/AWS/%s/%s" % (region, namespace, instanceId),
     headers=self.headers, status="*")
   assertions.assertBadRequest(self, response, "json")
   self.assertIn("Not supported.", response.body)