Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(52)

Delta Between Two Patch Sets: MoinMoin/storage/middleware/_tests/test_validation.py

Issue 11248043: Subscription validator (Closed)
Left Patch Set: Created 11 years, 9 months ago
Right Patch Set: Back to (el1, el2, ) style Created 11 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | MoinMoin/storage/middleware/validation.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 # Copyright: 2011,2012 MoinMoin:ThomasWaldmann 1 # Copyright: 2011,2012 MoinMoin:ThomasWaldmann
2 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. 2 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
3 3
4 """ 4 """
5 MoinMoin - validation tests 5 MoinMoin - validation tests
6 """ 6 """
7 7
8 8
9 from __future__ import absolute_import, division 9 from __future__ import absolute_import, division
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 print m.valid, m 60 print m.valid, m
61 assert valid 61 assert valid
62 62
63 def test_user(self): 63 def test_user(self):
64 meta = { 64 meta = {
65 keys.ITEMID: make_uuid(), 65 keys.ITEMID: make_uuid(),
66 keys.REVID: make_uuid(), 66 keys.REVID: make_uuid(),
67 keys.NAME: [u"user name", ], 67 keys.NAME: [u"user name", ],
68 keys.NAMESPACE: u"userprofiles", 68 keys.NAMESPACE: u"userprofiles",
69 keys.EMAIL: u"foo@example.org", 69 keys.EMAIL: u"foo@example.org",
70 keys.SUBSCRIPTIONS: [u"{0}:{1}".format(keys.ITEMID, make_uuid()),
71 u"{0}::foo".format(keys.NAME),
72 u"{0}::bar".format(keys.TAGS),
73 u"{0}::".format(keys.NAMERE),
74 u"{0}:userprofiles:a".format(keys.NAMEPREFIX),
75 ]
76 }
77
78 invalid_meta = {
79 keys.SUBSCRIPTIONS: [u"", u"unknown_tag:123",
80 u"{0}:123".format(keys.ITEMID),
81 u"{0}:foo".format(keys.NAME),
82 ]
70 } 83 }
71 84
72 state = {'trusted': False, # True for loading a serialized representati on or other trusted sources 85 state = {'trusted': False, # True for loading a serialized representati on or other trusted sources
73 keys.NAME: u'somename', # name we decoded from URL path 86 keys.NAME: u'somename', # name we decoded from URL path
74 keys.ACTION: u'SAVE', 87 keys.ACTION: u'SAVE',
75 keys.HOSTNAME: u'localhost', 88 keys.HOSTNAME: u'localhost',
76 keys.ADDRESS: u'127.0.0.1', 89 keys.ADDRESS: u'127.0.0.1',
77 keys.WIKINAME: u'ThisWiki', 90 keys.WIKINAME: u'ThisWiki',
78 keys.NAMESPACE: u'', 91 keys.NAMESPACE: u'',
79 } 92 }
80 93
81 m = UserMetaSchema(meta) 94 m = UserMetaSchema(meta)
82 valid = m.validate(state) 95 valid = m.validate(state)
83 assert m[keys.CONTENTTYPE].value == CONTENTTYPE_USER 96 assert m[keys.CONTENTTYPE].value == CONTENTTYPE_USER
84 if not valid: 97 if not valid:
85 for e in m.children: 98 for e in m.children:
86 print e.valid, e 99 print e.valid, e
87 print m.valid, m 100 print m.valid, m
88 assert valid 101 assert valid
102
103 m = UserMetaSchema(invalid_meta)
104 valid = m.validate(state)
105 assert not valid
106 for e in m.children:
107 if e.name in (keys.SUBSCRIPTIONS,):
108 for value in e:
109 assert not value.valid
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b