1 import sys, shutil
2 from grassyknoll.tests import *
3 from grassyknoll.lib.util import split_dot_name
4
5 from grassyknoll.collection.Collection import *
6
7 __all__=['makeTests']
8
13
14 testdocs=dict([make_doc(u'pants', 32, u'blue'),
15 make_doc(u'shirt', u'XL', u'red'),
16 make_doc(u'belt', 38, u'brown'),
17 make_doc(u'shoes', 14, u'black')])
18
19 testuids=[d.id for d in testdocs.itervalues()]
20
22
24 raise NotImplementedError
25
27 raise NotImplementedError
28
33
38
63
70
78
80
83
89
102
115
120
122 uids=self.collection.list()
123 assert_sorted_equals(uids, testuids)
124
125 uids=self.collection.delete([u'pants', u'shirt', u'hat'])
126 assert isinstance(uids, CollectionIds)
127 assert len(uids) == 3
128 assert_sorted_equals(uids, [u'hat', u'pants', u'shirt', ])
129
130 uids=self.collection.list()
131 assert len(uids) == 2
132 assert_sorted_equals(uids, [u'belt', u'shoes'])
133
135 """generate tests and inject them into caller's namespace.
136
137 @arg makeCollection: a L{Factory} that returns an empty L{Collection}.
138 This may be a L{Collection} subclass if its C{__init__} can be called
139 without arguments.
140 @type makeCollection: function or class
141
142 @arg name: a name to use for test subclasses of the form
143 'my_module.MyCollection'. If None, a name will be inferred.
144 @type name: str or None
145 """
146
147 frame=sys._getframe(1)
148 if name is not None:
149 mod, name = split_dot_name(name)
150 elif issubclass(makeCollection, Collection):
151 name=makeCollection.__name__
152
153 mod=frame.f_locals['__name__']
154 else:
155
156 raise ValueError, "must supply name"
157
158 class _empty(GenericEmptyTest):
159 make_collection=makeCollection
160 _empty.__name__='TestEmpty%s'%name
161
162 class _create(GenericCreateTest):
163 make_collection=makeCollection
164 _create.__name__='TestCreate%s'%name
165
166 class _test(GenericTest):
167 make_collection=makeCollection
168 _test.__name__='Test%s'%name
169
170 for cls in (_empty, _create, _test):
171 cls.__module__=mod
172 frame.f_locals[cls.__name__]=cls
173