-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_claims.py
executable file
·43 lines (40 loc) · 5.52 KB
/
test_claims.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
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import claims
checkme = {
'greeting': 'Hello world',
'area': 'IT Crowd',
}
assert claims.rule_matches(checkme, {'field': 'greeting', 'pattern': 'Hel+o'}) == True
assert claims.rule_matches(checkme, {'field': 'greeting', 'pattern': 'This is not there'}) == False
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}]}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}]}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'IT'}]}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}]}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'IT'}]}]}) == False
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'This is not there'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}, {'field': 'area', 'pattern': 'This is not there'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'area', 'pattern': 'This is not there'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'area', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'OR': [{'AND': [{'field': 'greeting', 'pattern': 'Hel+o'}, {'field': 'greeting', 'pattern': 'world'}]}, {'AND': [{'field': 'area', 'pattern': 'IT'}]}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}, {'AND': [{'field': 'area', 'pattern': 'IT'}]}]}) == True
assert claims.rule_matches(checkme, {'OR': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}, {'AND': [{'field': 'area', 'pattern': 'This is not there'}]}]}) == False
assert claims.rule_matches(checkme, {'OR': [{'AND': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}, {'field': 'area', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'OR': [{'field': 'greeting', 'pattern': 'Hel*o'}, {'field': 'greeting', 'pattern': 'world'}]}, {'field': 'area', 'pattern': 'This is not there'}]}) == False
assert claims.rule_matches(checkme, {'AND': [{'OR': [{'field': 'greeting', 'pattern': 'Hel*o'}, {'field': 'greeting', 'pattern': 'world'}]}, {'field': 'area', 'pattern': 'IT'}]}) == True
assert claims.rule_matches(checkme, {'AND': [{'OR': [{'field': 'greeting', 'pattern': 'This is not there'}, {'field': 'greeting', 'pattern': 'world'}]}, {'field': 'area', 'pattern': 'IT'}]}) == True