예제 #1
0
    def test_invalid_format():
        """
        GIVEN artifacts with format that is not supported
        WHEN _handle_string is called with the artifacts
        THEN FeatureNotImplementedError is raised.
        """
        artifacts = ColArt(open_api=OAColArt(type="string", format="unsupported"))

        with pytest.raises(exceptions.FeatureNotImplementedError):
            column._handle_string(artifacts=artifacts)
예제 #2
0
    def test_valid(format_, expected_type):
        """
        GIVEN artifacts and expected SQLALchemy type
        WHEN _handle_integer is called with the artifacts
        THEN the expected type is returned.
        """
        artifacts = ColArt(open_api=OAColArt(type="string", format=format_))

        string = column._handle_string(artifacts=artifacts)

        assert string == expected_type
예제 #3
0
    def test_valid_max_length(format_, expected_type):
        """
        GIVEN artifacts with max_length and given format
        WHEN _handle_string is called with the artifacts
        THEN a given expected type column with a maximum length is returned.
        """
        length = 1
        artifacts = ColArt(
            open_api=OAColArt(type="string", max_length=length, format=format_)
        )

        string = column._handle_string(artifacts=artifacts)

        assert isinstance(string, expected_type)
        assert string.length == length