def test_set_cookie(self): response = Response(self, self.controller.string_no_args) expire_time = get_gmt_now() + timedelta(hours=1) expire_string = format_date(expire_time) response.set_cookie('some_cookie', 'some_data_for_cookie', 1) cookie_string = 'some_cookie=some_data_for_cookie; Expires=%s; Path=/' % expire_string assert cookie_string == response.headers['Set-Cookie']
def setUp(self): _environ['wsgi.input'].seek(0) self.request = Request(_environ) self.response = Response(app, Controller().string_no_args)
def test_delete_cookie(self): response = Response(self, self.controller.string_no_args) cookie_string = 'some_cookie=deleted; Expires=Thu, Jan 01 1970 00:00:00 GMT' response.delete_cookie('some_cookie') assert cookie_string == response.headers['Set-Cookie']
def test_dictionary_args(self): response = Response(self.app, self.controller.dictionary_args, {'data': 'some data'}) assert 'Test: some data' == response.body
def test_string_args(self): response = Response(self.app, self.controller.string_args, {'data': 'some data'}) assert 'Test: some data' == response.body
def test_dictionary_no_args(self): response = Response(self.app, self.controller.dictionary_no_args)
def test_string_no_args(self): response = Response(self.app, self.controller.string_no_args) assert 'Hello, world!' == response.body
def test_no_controller(self): with self.assertRaises(frame.Error404): response = Response(self.app, None)
def setUp(self): app.request = DotDict({'headers': {}, 'cookies': {}}) app.response = Response(app, 'junk') self.session_interface = SessionInterface(app)