summaryrefslogtreecommitdiff
path: root/tests/test_viewstate.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_viewstate.py')
-rw-r--r--tests/test_viewstate.py25
1 files changed, 25 insertions, 0 deletions
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()