2011-07-16 09:47:06 +00:00
|
|
|
from libmproxy import encoding
|
|
|
|
import libpry
|
|
|
|
|
|
|
|
import cStringIO
|
|
|
|
import gzip, zlib
|
|
|
|
|
2011-07-18 03:16:47 +00:00
|
|
|
class uidentity(libpry.AutoTree):
|
|
|
|
def test_simple(self):
|
|
|
|
assert "string" == encoding.decode("identity", "string")
|
|
|
|
assert "string" == encoding.encode("identity", "string")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
|
|
|
def test_fallthrough(self):
|
2011-08-02 08:47:53 +00:00
|
|
|
assert None == encoding.decode("nonexistent encoding", "string")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
2011-07-18 03:16:47 +00:00
|
|
|
class ugzip(libpry.AutoTree):
|
2011-07-16 09:47:06 +00:00
|
|
|
def test_simple(self):
|
2011-07-18 03:16:47 +00:00
|
|
|
assert "string" == encoding.decode("gzip", encoding.encode("gzip", "string"))
|
2011-07-16 22:25:25 +00:00
|
|
|
assert None == encoding.decode("gzip", "bogus")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
2011-07-18 03:16:47 +00:00
|
|
|
class udeflate(libpry.AutoTree):
|
2011-07-16 09:47:06 +00:00
|
|
|
def test_simple(self):
|
2011-07-18 03:16:47 +00:00
|
|
|
assert "string" == encoding.decode("deflate", encoding.encode("deflate", "string"))
|
|
|
|
assert "string" == encoding.decode("deflate", encoding.encode("deflate", "string")[2:-4])
|
2011-07-16 22:25:25 +00:00
|
|
|
assert None == encoding.decode("deflate", "bogus")
|
2011-07-16 09:47:06 +00:00
|
|
|
|
|
|
|
tests = [
|
2011-07-18 03:16:47 +00:00
|
|
|
uidentity(),
|
|
|
|
ugzip(),
|
|
|
|
udeflate()
|
2011-07-16 09:47:06 +00:00
|
|
|
]
|