2015-08-01 12:53:13 +00:00
|
|
|
from netlib import encoding
|
|
|
|
|
2015-08-10 18:44:36 +00:00
|
|
|
|
2015-08-01 12:53:13 +00:00
|
|
|
def test_identity():
|
|
|
|
assert "string" == encoding.decode("identity", "string")
|
|
|
|
assert "string" == encoding.encode("identity", "string")
|
|
|
|
assert not encoding.encode("nonexistent", "string")
|
|
|
|
assert None == encoding.decode("nonexistent encoding", "string")
|
|
|
|
|
|
|
|
|
|
|
|
def test_gzip():
|
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"gzip",
|
|
|
|
encoding.encode(
|
|
|
|
"gzip",
|
|
|
|
"string"))
|
|
|
|
assert None == encoding.decode("gzip", "bogus")
|
|
|
|
|
|
|
|
|
|
|
|
def test_deflate():
|
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
|
|
|
"string"))
|
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
|
|
|
"string")[
|
|
|
|
2:-
|
|
|
|
4])
|
|
|
|
assert None == encoding.decode("deflate", "bogus")
|