Changeset 6550 for main/waeup.sirp/trunk/src
- Timestamp:
- 23 Jul 2011, 15:12:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_catalog.py
r6548 r6550 35 35 AccessCode, AccessCodeBatch, invalidate_accesscode, disable_accesscode) 36 36 from waeup.sirp.accesscodes.workflow import INITIALIZED, USED, DISABLED 37 from waeup.sirp.accesscodes.catalog import AccessCodeQueryResultItem 37 from waeup.sirp.accesscodes.catalog import AccessCodeQueryResultItem, search 38 38 39 39 class CatalogTestSetup(FunctionalTestCase): … … 172 172 class FakeView(object): 173 173 # A view we can use in tests. Provides only the neccessary methods. 174 flashed = [] 174 175 def url(self, context): 175 176 pass 177 def flash(self, msg): 178 self.flashed.append(msg) 176 179 177 180 class AccessCodeQueryResultItemTests(CatalogTestSetup): … … 190 193 return 191 194 195 class SearchTests(CatalogTestSetup): 196 # Tests for the search() function 197 198 layer = FunctionalLayer 199 200 def setUp(self): 201 super(SearchTests, self).setUp() 202 self.view = FakeView() 203 return 204 205 def test_search_none(self): 206 # if we search none we will get it. Also a warning is displayed. 207 result = search(view=self.view) 208 self.assertTrue(result is None) 209 self.assertEqual(self.view.flashed, ['Empty search string.']) 210 return 211 212 def test_search_history(self): 213 # we can search for history entries 214 result = search( 215 query='initialized', # A word that appears in all items' hist 216 searchtype='history', view=self.view) 217 self.assertEqual(len(result), 3) 218 return 219 220 def test_search_batch_serial(self): 221 # we can search for batch serials 222 result = search( 223 query=2, 224 searchtype='batch_serial', view=self.view) 225 self.assertEqual(len(result), 1) 226 self.assertEqual(result[0].code, 'APP-1-33333333') 227 return 228 229 def test_search_freestyle(self): 230 # we can even search for arbitrary fields 231 result = search( 232 query='APP-1-11111111', 233 searchtype='code', view=self.view) 234 self.assertEqual(len(result), 1) 235 self.assertEqual(result[0].code, 'APP-1-11111111') 236 return
Note: See TracChangeset for help on using the changeset viewer.