Exemple #1
0
    def generate_spec(self) -> dict:
        """
        extend the spec to add custom descriptions of error codes
        """
        responses = super().generate_spec()

        all_codes = set(self.codes) | self.code_models.keys()
        for code in all_codes:
            description = self.code_descriptions.get(code)
            if description:
                responses[parse_code(code)]["description"] = description

        return responses
Exemple #2
0
def test_parse_code():
    with pytest.raises(TypeError):
        assert parse_code(200) == 200

    assert parse_code('200') is None
    assert parse_code('HTTP_404') == '404'
Exemple #3
0
def test_parse_code():
    with pytest.raises(TypeError):
        assert parse_code(200) == 200

    assert parse_code("200") is None
    assert parse_code("HTTP_404") == "404"