예제 #1
0
    def test_save_body(self, example_response, includes):
        """Save a key from the body into the right name
        """
        example_response["save"] = {"body": {"test_code": "code"}}

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        saved = r._save_value("body", example_response["body"])

        assert saved == {"test_code": example_response["body"]["code"]}
예제 #2
0
    def test_bad_save(self, save_from, example_response, includes):
        example_response["save"] = {save_from: {"abc": "123"}}

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        saved = r._save_value(save_from, {})

        assert not saved

        assert r.errors
예제 #3
0
    def test_save_header(self, example_response, includes):
        """Save a key from the headers into the right name
        """
        example_response["save"] = {"headers": {"next_location": "location"}}

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        saved = r._save_value("headers", example_response["headers"])

        assert saved == {"next_location": example_response["headers"]["location"]}
예제 #4
0
    def test_save_redirect_query_param(self, example_response, includes):
        """Save a key from the query parameters of the redirect location
        """
        example_response["save"] = {"redirect_query_params": {"test_search": "search"}}

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        saved = r._save_value("redirect_query_params", {"search": "breadsticks"})

        assert saved == {"test_search": "breadsticks"}
예제 #5
0
    def test_save_body_nested_list(self, example_response, includes):
        """Save a key from the body into the right name
        """
        example_response["body"]["nested"] = {"subthing": ["abc", "def"]}
        example_response["save"] = {"body": {"test_nested_thing": "nested.subthing.0"}}

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        saved = r._save_value("body", example_response["body"])

        assert saved == {
            "test_nested_thing": example_response["body"]["nested"]["subthing"][0]
        }