Example #1
0
class RequestHandlerTest(unittest.TestCase):
    def setUp(self):
        self.server_mock = pmock.Mock()
        self.server_mock.server_root_dir = "rootdirectory_for_server"
        self.request_handler = RequestHandler(self.__connectionStub(), pmock.Mock(), self.server_mock)

    def tearDown(self):
        self.request_handler.close()
        self.server_mock.verify()

    def testDoPostCallsServerNotifyOnDoPost(self):
        post_data = "DATA CONTENT"
        full_request_path = "/tester/gui.html?foobar=goofy"
        request_path = "/tester/gui.html"
        self.request_handler.path = full_request_path
        self.server_mock.expects(pmock.once()).notifyOnDoPost(pmock.eq(post_data), pmock.eq(request_path))

        self.__mockHeaders(pmock)
        self.request_handler.rfile = self.__mockRfile(post_data, pmock)
        try:
            self.request_handler.do_POST()
        # We are letting some errors happen, although mocking as
        # much as possible there is not way we can use composition to
        # get async and http server init code out.
        except TypeError, e:
            pass
Example #2
0
class RequestHandlerTest(unittest.TestCase):

  
  def setUp(self):
    self.server_mock = pmock.Mock()
    self.server_mock.server_root_dir = "rootdirectory_for_server"
    self.request_handler = RequestHandler(self.__connectionStub(), 
                                          pmock.Mock(), self.server_mock)
    
    
  def tearDown(self):
    self.request_handler.close()
    self.server_mock.verify()    

  
  def testDoPostCallsServerNotifyOnDoPost(self):
    post_data = "DATA CONTENT"
    full_request_path = "/tester/gui.html?foobar=goofy"
    request_path = "/tester/gui.html"
    self.request_handler.path = full_request_path
    self.server_mock.expects(pmock.once()).notifyOnDoPost(pmock.eq(post_data), 
                                                      pmock.eq(request_path))

    self.__mockHeaders(pmock)
    self.request_handler.rfile = self.__mockRfile(post_data, pmock)
    try:
      self.request_handler.do_POST()
    # We are letting some errors happen, although mocking as 
    # much as possible there is not way we can use composition to 
    # get async and http server init code out. 
    except TypeError, e:
      pass
Example #3
0
 def setUp(self):
     self.server_mock = pmock.Mock()
     self.server_mock.server_root_dir = "rootdirectory_for_server"
     self.request_handler = RequestHandler(self.__connectionStub(), pmock.Mock(), self.server_mock)
Example #4
0
 def setUp(self):
   self.server_mock = pmock.Mock()
   self.server_mock.server_root_dir = "rootdirectory_for_server"
   self.request_handler = RequestHandler(self.__connectionStub(), 
                                         pmock.Mock(), self.server_mock)