2011-07-16 09:47:06 +00:00
|
|
|
from libmproxy import encoding
|
|
|
|
|
2015-05-30 00:03:28 +00:00
|
|
|
|
2012-06-09 01:42:43 +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")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
|
|
|
|
2012-06-09 01:42:43 +00:00
|
|
|
def test_gzip():
|
2015-05-30 00:03:28 +00:00
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"gzip",
|
|
|
|
encoding.encode(
|
|
|
|
"gzip",
|
|
|
|
"string"))
|
2012-06-09 01:42:43 +00:00
|
|
|
assert None == encoding.decode("gzip", "bogus")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
|
|
|
|
2012-06-09 01:42:43 +00:00
|
|
|
def test_deflate():
|
2015-05-30 00:03:28 +00:00
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
|
|
|
"string"))
|
|
|
|
assert "string" == encoding.decode(
|
|
|
|
"deflate",
|
|
|
|
encoding.encode(
|
|
|
|
"deflate",
|
|
|
|
"string")[
|
|
|
|
2:-
|
|
|
|
4])
|
2012-06-09 01:42:43 +00:00
|
|
|
assert None == encoding.decode("deflate", "bogus")
|