def testUrl(self): req = mock_objects.get_request(book_site.SiteController(), '/') url = req.url('books.chapters.search', 'foo', '1') self.assertEqual('http://localhost/books/foo/chapters/1/search', url) url = req.url('books.chapters.search', 'foo', '1', baseUrl='https://localhost') self.assertEqual('https://localhost/books/foo/chapters/1/search', url) url = req.url('books.chapters.search', 'foo', '1', [('foo', 'bar'), ('bam', 'baz')]) self.assertEqual('http://localhost/books/foo/chapters/1/search?foo=bar&bam=baz', url)
def testHandler(self): controller = book_site.SiteController() handler = mock_objects.get_handler(controller) request = mock_objects.get_request(controller, '/books/foo') handler.addCallback(CallbackRecorder(1)) handler.addCallback(CallbackRecorder(2)) response = handler.getResponse(request) self.failUnlessEqual(response.get(), 'foo') self.assertEquals(CallbackRecorder.callbacks, ['request 1', 'request 2', 'method 1', 'method 2', 'response 2', 'response 1'])
def testGetData(self): req = mock_objects.get_request(book_site.SiteController(), '/?param=blah;param=blah2;param2=foo') self.failUnlessEqual(req.GET['param'], ['blah', 'blah2']) self.failUnlessEqual(req.GET['param2'], 'foo')