diff options
| author | Yuval Adam <_@yuv.al> | 2018-02-20 15:05:02 +0100 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-02-20 15:05:02 +0100 |
| commit | 400801d603bad8cb92fe6c0b564f71acfd1ba7d6 (patch) | |
| tree | 6fe9a40f76d5be937df418433044ac6666cac384 /tests | |
| parent | adec33cfea063cb6de603feb30fc147a8f567a87 (diff) | |
Split test files
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_parse.py (renamed from tests/test_core.py) | 35 | ||||
| -rw-r--r-- | tests/test_viewstate.py | 25 |
2 files changed, 33 insertions, 27 deletions
diff --git a/tests/test_core.py b/tests/test_parse.py index 0c71a62..170d5ef 100644 --- a/tests/test_core.py +++ b/tests/test_parse.py @@ -3,53 +3,34 @@ import pytest from viewstate import * -class TestViewState(object): +class TestParse(object): - def test_blank(self): - vs = ViewState() - assert not vs.is_valid() - - def test_is_valid(self): - for s in ['ngcs', 'mot']: - 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() - - def test_parse_int_value(self): + def test_int_value(self): vs = ViewState(raw=b'\xff\x01\x02\x88\x01') assert vs.decode() == 136 - def test_parse_const_value(self): + def test_const_value(self): vs = ViewState(raw=b'\xff\x01\x67') assert vs.decode() is True - def test_parse_string_value(self): + def test_string_value(self): s = 'abcdefghij' vs = ViewState(raw=b'\xff\x01\x05\x0a' + s.encode()) assert vs.decode() == s - def test_parse_simple_dict(self): + def test_simple_dict(self): vs = ViewState(raw=b'\xff\x01\x18\x02\x05\x01a\x05\x01b\x05\x01c\x05\x01d') assert vs.decode() == {'a': 'b', 'c': 'd'} - def test_parse_simple_list(self): + def test_simple_list(self): vs = ViewState(raw=b'\xff\x01\x16\x05\x05\x01a\x05\x01b\x05\x01c\x05\x01d\x05\x01e') assert vs.decode() == ['a', 'b', 'c', 'd', 'e'] - def test_parse_simple_pair(self): + def test_simple_pair(self): vs = ViewState(raw=b'\xff\x01\x0f\x67\x68') assert vs.decode() == (True, False) - def test_parse_complex_pair(self): + def test_complex_pair(self): vs = ViewState() vs.raw = b'\xff\x01\x0f\x67\x0f\x68\x66' assert vs.decode() == (True, (False, 0)) diff --git a/tests/test_viewstate.py b/tests/test_viewstate.py new file mode 100644 index 0000000..258eb7f --- /dev/null +++ b/tests/test_viewstate.py @@ -0,0 +1,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']: + 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() |
