Exemplo n.º 1
0
def checkTotalAboveZero(self, bundle, expectedValue):
    if totalAboveZero(self, bundle) != expectedValue:
        if expectedValue:
            raise ResponseError("Empty response body or empty search set")
        else:
            raise ResponseError(
                "Non-empty response body or non-empty search set")
Exemplo n.º 2
0
def checkETagHeaderPresent(headers, expectedValue):
    if ETagHeaderPresent(headers) != expectedValue:
        if expectedValue:
            raise ResponseError("ETag header is missing from the response")
        else:
            raise ResponseError(
                "ETag header found in response, while it was not expected")
Exemplo n.º 3
0
def checkOperationOutcomeIssueCode(self, OO, code, expectedValue):
    if operationOutcomeIssueCode(self, OO, code) != expectedValue:
        if expectedValue:
            raise ResponseError("Expected code: " + code + " not found")
        else:
            raise ResponseError("Code: " + code +
                                " found, which was not expected")
Exemplo n.º 4
0
def checkBatchSucces(self, inputBody, responseBody, expectedValue):
    if batchSucces(self, inputBody, responseBody) != expectedValue:
        if expectedValue:
            raise ResponseError("Not all entries in the batch succeeded")
        else:
            raise ResponseError(
                "All entries in the batch succeeded, while this was not expected"
            )
Exemplo n.º 5
0
def checkResourceIDpresent(self, bundle, id, expectedValue):
    if resourceIDpresent(self, bundle, id) != expectedValue:
        if expectedValue:
            raise ResponseError("Expected to find resource with id=" + id +
                                ", but it was not found")
        else:
            raise ResponseError("Resource with id=" + id +
                                " was found, but it was not expected")
Exemplo n.º 6
0
def checkTotalEquals(self, bundle, number, expectedValue):
    if totalEquals(self, bundle, number) != expectedValue:
        if expectedValue:
            raise ResponseError(
                "Total number of resources does not match expected number of resources"
            )
        else:
            raise ResponseError(
                "Total number of resources matches unexpected value")
Exemplo n.º 7
0
def checkElementsPresent(self, resource, elements, expectedValue):
    if elementsPresent(self, resource, elements) != expectedValue:
        if expectedValue:
            raise ResponseError("Not all listed elements (" +
                                ', '.join(elements) +
                                ") are present in response body")
        else:
            raise ResponseError("All listed elements (" + ', '.join(elements) +
                                ") are present in response body")
Exemplo n.º 8
0
def checkResourceTypePresent(self, bundle, type, expectedValue):
    if resourceTypePresent(self, bundle, type) != expectedValue:
        if expectedValue:
            raise ResponseError(
                "Resource of type: " + type +
                " not found in response body, while it was expected")
        else:
            raise ResponseError(
                "Resource of type: " + type +
                " found in response body, while it was not expected")
Exemplo n.º 9
0
def checkNoOtherElementsPresent(self, resource, elements, expectedValue):
    if noOtherElementsPresent(self, resource, elements) != expectedValue:
        if expectedValue:
            raise ResponseError("Other elements than listed elements (" +
                                ', '.join(elements) +
                                ") are present in response body")
        else:
            raise ResponseError("No other elements than listed elements (" +
                                ', '.join(elements) +
                                ") are present in response body")
Exemplo n.º 10
0
def checkFormat(response, expectedFormat):
    print "expected format: " + expectedFormat
    actualFormat = format(response)
    if actualFormat != expectedFormat:
        raise ResponseError("Expected format of response body is " +
                            str(expectedFormat) +
                            ", but the following format was found: " +
                            str(actualFormat))
Exemplo n.º 11
0
 def test_catch_response_response_error(self):
     s = self.get_client()
     try:
         with s.get("/fail", catch_response=True) as r:
             raise ResponseError("response error")
     except ResponseError as e:
         self.fail("ResponseError should not have been raised")
     
     self.assertEqual(1, self.environment.stats.total.num_requests)
     self.assertEqual(1, self.environment.stats.total.num_failures)
Exemplo n.º 12
0
 def test_catch_response(self):
     self.assertEqual(500, self.locust.client.get("/fail").status_code)
     self.assertEqual(1, self.num_failures)
     self.assertEqual(0, self.num_success)
     
     with self.locust.client.get("/ultra_fast", catch_response=True) as response: pass
     self.assertEqual(1, self.num_failures)
     self.assertEqual(1, self.num_success)
     
     with self.locust.client.get("/ultra_fast", catch_response=True) as response:
         raise ResponseError("Not working")
     
     self.assertEqual(2, self.num_failures)
     self.assertEqual(1, self.num_success)
Exemplo n.º 13
0
def checkResponse(actualResponse, expectedResponse):
    if str(actualResponse) not in str(expectedResponse):
        raise ResponseError("Response code " + str(actualResponse) +
                            " does not match expected response code(s) " +
                            str(expectedResponse))
Exemplo n.º 14
0
def checkEmptyResponseBody(self, response, expectedValue):
    if emptyResponseBody(self, response) != expectedValue:
        if expectedValue:
            raise ResponseError("Non-empty response body")
        else:
            raise ResponseError("Empty response body")
Exemplo n.º 15
0
def checkTagPresent(self, resource, tag, expectedValue):
    if tagPresent(self, resource, tag) != expectedValue:
        if expectedValue:
            raise ResponseError(tag + " tag is missing from response body")
        else:
            raise ResponseError(tag + " tag was found in response body")
 def validate_resp(self, status_code):
     if status_code != 200:
         print(f"Received error response: {status_code}")
         self.environment.runner.quit()
         raise ResponseError()