summaryrefslogtreecommitdiff
path: root/tests/__init__.py
blob: f203615a21ba56cc7fae6b31d464d2093c895161 (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
import unittest

from viewstate import ViewState

class TestViewState(unittest.TestCase):

    def test_blank(self):
        vs = ViewState()
        self.assertFalse(vs.is_valid())

    def test_is_valid(self):
        with open('samples/ngcs.sample', 'r') as f:
            vs = ViewState(f.read())
            self.assertTrue(vs.is_valid())

    def test_invalid_decode(self):
        with self.assertRaises(Exception):
            vs = ViewState()
            vs.raw = b'\x01\x02'
            vs.decode()

    def test_parse_const_value(self):
        vs = ViewState()
        vs.raw = b'\xff\x01\x67'
        self.assertEqual(vs.decode(), True)

if __name__ == '__main__':
    unittest.main()