Пример #1
0
    def test_unique_name(self, spec):
        properties = {
            "id": {
                "type": "integer",
                "format": "int64"
            },
            "name": {
                "type": "string",
                "example": "doggie"
            },
        }

        name = get_unique_schema_name(spec.components, "Pet")
        assert name == "Pet"

        spec.components.schema("Pet", properties=properties)
        with pytest.warns(UserWarning,
                          match="Multiple schemas resolved to the name Pet"):
            name_1 = get_unique_schema_name(spec.components, "Pet")
        assert name_1 == "Pet1"

        spec.components.schema("Pet1", properties=properties)
        with pytest.warns(UserWarning,
                          match="Multiple schemas resolved to the name Pet"):
            name_2 = get_unique_schema_name(spec.components, "Pet")
        assert name_2 == "Pet2"
Пример #2
0
    def test_unique_name(self, spec):
        properties = {
            'id': {'type': 'integer', 'format': 'int64'},
            'name': {'type': 'string', 'example': 'doggie'},
        }

        name = get_unique_schema_name(spec.components, 'Pet')
        assert name == 'Pet'

        spec.components.schema('Pet', properties=properties)
        with pytest.warns(UserWarning, match='Multiple schemas resolved to the name Pet'):
            name_1 = get_unique_schema_name(spec.components, 'Pet')
        assert name_1 == 'Pet1'

        spec.components.schema('Pet1', properties=properties)
        with pytest.warns(UserWarning, match='Multiple schemas resolved to the name Pet'):
            name_2 = get_unique_schema_name(spec.components, 'Pet')
        assert name_2 == 'Pet2'