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():
|
2015-09-17 14:31:50 +00:00
|
|
|
assert b"string" == encoding.decode("identity", b"string")
|
|
|
|
assert b"string" == encoding.encode("identity", b"string")
|
|
|
|
assert not encoding.encode("nonexistent", b"string")
|
|
|
|
assert not encoding.decode("nonexistent encoding", b"string")
|
2015-08-01 12:53:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_gzip():
|
2015-09-15 17:12:15 +00:00
|
|
|
assert b"string" == encoding.decode(
|
2015-08-01 12:53:13 +00:00
|
|
|
"gzip",
|
|
|
|
encoding.encode(
|
|
|
|
"gzip",
|
2015-09-15 17:12:15 +00:00
|
|
|
b"string"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert encoding.decode("gzip", b"bogus") is None
|
2015-08-01 12:53:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_deflate():
|
2015-09-15 17:12:15 +00:00
|
|
|
assert b"string" == encoding.decode(
|
2015-08-01 12:53:13 +00:00
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
2015-09-15 17:12:15 +00:00
|
|
|
b"string"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert b"string" == encoding.decode(
|
2015-08-01 12:53:13 +00:00
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
2015-09-15 17:12:15 +00:00
|
|
|
b"string"
|
|
|
|
)[2:-4]
|
|
|
|
)
|
|
|
|
assert encoding.decode("deflate", b"bogus") is None
|