Пример #1
0
 def testOrAnythingUnderTheMagicDirectoryToo(self):
     request = self.make_request('/app1/__/blah/blah/blah', Zope=True)
     task = Task(StubChannel(), request)
     try:
         task.process()
     except Response, response:
         self.assertEqual(response.code, 404)
Пример #2
0
 def testSubdirStillMatches(self):
     request = self.make_request('/app1/foo/bar.html', Zope=True)
     task = Task(StubChannel(), request)
     try:
         task.process()
     except Response, response:
         self.assertEqual(response.code, 200)
Пример #3
0
 def testDirectlyAccessingMagicDirectoryRaises404(self):
     request = self.make_request('/app1/__', Zope=True)
     task = Task(StubChannel(), request)
     try:
         task.process()
     except Response, response:
         self.assertEqual(response.code, 404)
Пример #4
0
 def testAppNotThereRaises404(self):
     request = self.make_request('/not-there', Zope=True)
     task = Task(StubChannel(), request)
     try:
         task.process()
     except Response, response:
         self.assertEqual(response.code, 404)
Пример #5
0
 def testBasic(self):
     request = self.make_request('/index.html', Zope=True)
     task = Task(StubChannel(), request)
     try:
         task.process()
     except Response, response:
         pass
Пример #6
0
    def testFailInDevMode(self):
        task = DUMMY_TASK()
        task.dev_mode = True
        task.channel = StubChannel()
        try:
            raise Exception("Yarrr!")
        except:
            task.fail()

        # Traceback and content length depend on incidental circumstances.
        expected = [
            "HTTP/1.0 500 Internal Server Error"
            # "Content-Length: x"
            ,
            "Content-Type: text/plain",
            "",
            "Internal Server Error",
            "",
            "Traceback (most recent call last):"
            # ...
            ,
            'Exception: Yarrr!'
        ]
        actual = task.channel.getvalue().splitlines()
        actual = actual[:1] + actual[2:7] + actual[-1:]
        self.assertEqual(expected, actual)
Пример #7
0
 def testNonRootAppWithNoMagicDirectoryRaises500(self):
     request = self.make_request('/app1', Zope=True)
     task = Task(StubChannel(), request)
     os.remove(self.convert_path('root/app1/__/app.py'))
     os.remove(self.convert_path('root/app1/__/app.pyc'))
     os.rmdir(self.convert_path('root/app1/__'))
     try:
         task.process()
     except Response, response:
         self.assertEqual(response.code, 500)
Пример #8
0
 def testEtcPasswdCaughtByFindApp(self):
     request = self.make_request(
         '../../../../../../../../../../etc/master.passwd', Zope=True)
     task = Task(StubChannel(), request)
     expected = [
         "HTTP/1.0 500 Internal Server Error", "Content-Length: 25",
         "Content-Type: text/plain", "", "Internal Server Error", "", ""
     ]
     expected = '\r\n'.join(expected)
     actual = task.channel.getvalue()
     self.assertEqual(expected, actual)
Пример #9
0
    def testFailInDepMode(self):
        task = DUMMY_TASK()
        task.dev_mode = False
        task.channel = StubChannel()
        try:
            raise Exception("Yarrr!")
        except:
            task.fail()

        expected = [
            "HTTP/1.0 500 Internal Server Error", "Content-Length: 25",
            "Content-Type: text/plain", "", "Internal Server Error", ""
        ]
        actual = task.channel.getvalue().splitlines()
        self.assertEqual(expected, actual)