Beispiel #1
0
    def test_encode_path_error(value):
        """ Test that the JsonSerializer.encode_path raises an error if no encoding is defined. """
        # Arrange
        value = b"foobar"

        # Act & Assert
        with pytest.raises(NotImplementedError):
            JsonSerializer.encode_path(value)
Beispiel #2
0
    def test_encode_numeric_error():
        """ Test that the JsonSerializer.encode_numeric raises an error if no encoding is defined. """
        # Arrange
        value = "3.121"

        # Act & Assert
        with pytest.raises(NotImplementedError):
            JsonSerializer.encode_numeric(value)
Beispiel #3
0
    def test_encode_collection_error():
        """ Test that the JsonSerializer.encode_collection raises an error if no encoding is defined. """
        # Arrange
        value = bytearray(10)

        # Act & Assert
        with pytest.raises(NotImplementedError):
            JsonSerializer.encode_collection(value)
Beispiel #4
0
    def test_encode_datetime_error():
        """ Test that the JsonSerializer.encode_datetime raises an error if no encoding is defined. """
        # Arrange
        value = "not a datetime"

        # Act & Assert
        with pytest.raises(NotImplementedError):
            JsonSerializer.encode_datetime(value)
Beispiel #5
0
    def test_encode_numeric(value, expected):
        """ Test that the JsonSerializer.encode_numeric encodes values as expected. """
        # Arrange

        # Act
        result = JsonSerializer.encode_numeric(value)

        # Assert
        assert (result == expected) or (isnan(result) and isnan(expected))
Beispiel #6
0
    def test_encode_path(value, expected):
        """ Test that the JsonSerializer.encode_collection encodes values as expected. """
        # Arrange

        # Act
        result = JsonSerializer.encode_path(value)

        # Assert
        assert result == expected
Beispiel #7
0
    def test_encode_datetime(value, expected):
        """ Test that the JsonSerializer.encode_datetime encodes values as expected. """
        # Arrange

        # Act
        result = JsonSerializer.encode_datetime(value)

        # Assert
        assert result == expected