~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/publisher/test_publisher.py

  • Committer: William Grant
  • Date: 2012-06-28 01:52:02 UTC
  • Revision ID: me@williamgrant.id.au-20120628015202-f6ru7o367gt6nvgz
Hah

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
class OfferingAddProject(View):
95
95
    pass
96
96
 
 
97
class OfferingWorksheets(View):
 
98
    pass
 
99
 
 
100
class OfferingWorksheetMarks(View):
 
101
    pass
 
102
 
 
103
class OfferingWorksheetCSVMarks(View):
 
104
    pass
 
105
 
97
106
def root_to_subject_or_user(root, name):
98
107
    if name.startswith('~'):
99
108
        return root.users.get(name[1:])
184
193
                          viewset='browser')
185
194
        self.rtr.add_view(Offering, ('+projects', '+index'), OfferingProjects,
186
195
                          viewset='browser')
 
196
        self.rtr.add_view(Offering, ('+worksheets', '+index'),
 
197
                          OfferingWorksheets, viewset='browser')
 
198
        self.rtr.add_view(Offering, ('+worksheets', '+marks', '+index'),
 
199
                          OfferingWorksheetMarks, viewset='browser')
 
200
        self.rtr.add_view(Offering, ('+worksheets', '+marks', 'marks.csv'),
 
201
                          OfferingWorksheetCSVMarks, viewset='browser')
187
202
 
188
203
    def testOneRoute(self):
189
204
        assert_equal(self.rtr.resolve('/info1'),
311
326
              OfferingProjects, ())
312
327
             )
313
328
 
 
329
    def testAnotherDefaultDeepView(self):
 
330
        assert_equal(self.rtr.resolve('/info1/2009/1/+worksheets'),
 
331
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
332
              OfferingWorksheets, ())
 
333
             )
 
334
 
 
335
    def testReallyDeepView(self):
 
336
        assert_equal(
 
337
             self.rtr.resolve('/info1/2009/1/+worksheets/+marks/marks.csv'),
 
338
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
339
              OfferingWorksheetCSVMarks, ())
 
340
             )
 
341
 
 
342
    def testDefaultReallyDeepView(self):
 
343
        assert_equal(self.rtr.resolve('/info1/2009/1/+worksheets/+marks'),
 
344
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
345
              OfferingWorksheetMarks, ())
 
346
             )
 
347
 
314
348
    def testNamedRouteWithDeepView(self):
315
349
        assert_equal(self.rtr.resolve('/info1/2009/1/+projects/p1'),
316
350
             (self.r.subjects['info1'].offerings[(2009, 1)].projects['p1'],
326
360
        assert_equal(self.rtr.resolve('/~jsmith/foo/bar'),
327
361
             (self.r.users['jsmith'], UserServeView, ('foo', 'bar')))
328
362
 
 
363
    def testTrailingSlashResolvesToDefaultView(self):
 
364
        assert_equal(
 
365
             self.rtr.resolve('/info1/2009/1/'),
 
366
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
367
              OfferingIndex, ())
 
368
             )
 
369
 
 
370
    def testTrailingSlashResolvesToDeepDefaultView(self):
 
371
        assert_equal(
 
372
             self.rtr.resolve('/info1/2009/1/+worksheets/+marks/'),
 
373
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
374
              OfferingWorksheetMarks, ())
 
375
             )
 
376
 
 
377
    def testSubpathIndicatesTrailingSlash(self):
 
378
        assert_equal(
 
379
             self.rtr.resolve('/info1/2009/1/+index/'),
 
380
             (self.r.subjects['info1'].offerings[(2009, 1)],
 
381
              OfferingIndex, ('',))
 
382
             )
329
383
 
330
384
class TestGeneration(BaseTest):
331
385
    def setUp(self):