~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: 2010-02-25 03:18:21 UTC
  • Revision ID: grantw@unimelb.edu.au-20100225031821-mi9a2tm5679fht4d
Shuffle things around so that req.user and req.store only construct when actually retrieved, and ensure they're not retrieved for media files. Saves 50ms of DB connection time per request.

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'],