aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_encoding.py
blob: 61caf507b1f8567ab7a2fe8e5a591d6c71973757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from libmproxy import encoding
import libpry

class uidentity(libpry.AutoTree):
    def test_simple(self):
        assert "string" == encoding.decode("identity", "string")
        assert "string" == encoding.encode("identity", "string")
        assert not encoding.encode("nonexistent", "string")

    def test_fallthrough(self):
        assert None == encoding.decode("nonexistent encoding", "string")

class ugzip(libpry.AutoTree):
    def test_simple(self):
        assert "string" == encoding.decode("gzip", encoding.encode("gzip", "string"))
        assert None == encoding.decode("gzip", "bogus")

class udeflate(libpry.AutoTree):
    def test_simple(self):
        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")

tests = [
    uidentity(),
    ugzip(),
    udeflate()
]