Beispiel #1
0
 def test_post_request_without_write(self):
     middleware = DBRoutingMiddleware()
     request = Mock(spec=HttpRequest, method='POST')
     request.session = {}
     output = middleware.process_request(request)
     self.assertIsNone(output)
     self.assertTrue(is_thread_readwrite())
     response = Mock()
     output = middleware.process_response(request, response)
     self.assertEqual(output, response)
     # No write - did not pin
     self.assertNotIn(PINNING_KEY, request.session)
Beispiel #2
0
 def test_post_request_with_write(self):
     middleware = DBRoutingMiddleware()
     request = Mock(spec=HttpRequest, method='POST')
     request.session = {}
     output = middleware.process_request(request)
     self.assertIsNone(output)
     self.assertTrue(is_thread_readwrite())
     set_db_written_flag()
     response = Mock()
     output = middleware.process_response(request, response)
     self.assertEqual(output, response)
     # Db was written, so pin
     self.assertTrue(request.session[PINNING_KEY] > datetime.now())