-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
46 lines (33 loc) · 1.32 KB
/
tests.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import unittest
from base import validate, StringConditionsException
class TestSequenceFunctions(unittest.TestCase):
def test_simple( self ):
try:
validate( "foo bar", ["foo", "bar"] )
except StringConditionsException:
self.fail( "Condition failed: foo bar" )
self.assertRaises( StringConditionsException, validate, "foo bar", ["foo"] )
def test_and( self ):
try:
validate( "foo&bar", ["foo", "bar"] )
except StringConditionsException:
self.fail( "Condition failed: foo&bar" )
self.assertRaises( StringConditionsException, validate, "foo&bar", ["foo"] )
def test_or( self ):
try:
validate( "foo|bar", ["foo"] )
validate( "foo|bar", ["bar"] )
validate( "foo|bar", ["foo", "bar"] )
except StringConditionsException:
self.fail( "Condition failed: foo|bar" )
self.assertRaises( StringConditionsException, validate, "foo&bar", [] )
def test_mixed( self ):
try:
validate( "foo&bar|eggs apples", ["foo", "bar", "apples"] )
validate( "foo&bar|eggs apples", ["foo", "eggs", "apples"] )
validate( "foo&bar|eggs apples", ["foo", "bar", "eggs", "apples"] )
except StringConditionsException:
self.fail( "Condition failed: foo&bar|eggs apples" )
self.assertRaises( StringConditionsException, validate, "foo&bar|eggs apples", ["foo", "bar"] )
if __name__ == '__main__':
unittest.main()