summaryrefslogtreecommitdiff
path: root/tests/test_viewstate.py
blob: 0b69e1d3bf29faf6bd9adc1f53b2540174da2c52 (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
import pytest

from viewstate import *


class TestViewState(object):

    def test_blank(self):
        vs = ViewState()
        assert not vs.is_valid()

    def test_is_valid(self):
        for s in ['ngcs', 'mot', 'ecom']:
            with open(f'tests/samples/{s}.sample', 'r') as f:
                vs = ViewState(f.read())
                assert vs.is_valid() is True

    def test_invalid_base64(self):
        with pytest.raises(ViewStateException):
            vs = ViewState('hello')

    def test_invalid_decode(self):
        with pytest.raises(ViewStateException):
            vs = ViewState(raw=b'\x01\x02')
            vs.decode()