def test_encode_tagset_values(values, expected): """Test that we can properly encode data into the expected format""" header = encode_tagset_values(values) assert expected == header # Ensure what we generate also parses correctly assert values == decode_tagset_string(header)
def test_encode_tagset_values_strip_spaces(): """Test that leading and trailing spaces are stripped from keys and values""" # Leading/trailing spaces are striped values = {" key ": " value "} res = encode_tagset_values(values) assert "key=value" == res assert {"key": "value"} == decode_tagset_string(res)
def test_decode_tagset_string_malformed(header): """Test that the provided malformed header values raise an exception""" with pytest.raises(TagsetDecodeError): decode_tagset_string(header)
def test_decode_tagset_string(header, expected): """Test that provided header value is parsed as expected""" assert expected == decode_tagset_string(header)