def test_views_not_implemented(self): load_settings('test_templates/settings.py') from ukumuku.views import View import ukumuku req = mock.Mock() resp = Response() view = View() view.on_get(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501) resp = Response() view.on_post(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501) resp = Response() view.on_put(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501) resp = Response() view.on_patch(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501) resp = Response() view.on_head(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501) resp = Response() view.on_delete(req, resp) self.assertEqual(resp.status, ukumuku.HTTP_501)
def test_simple_render_template(self): load_settings('test_templates/settings.py') from ukumuku.templates import template_engine result = template_engine.render_template('index.html', {'name': 'Andrix'}) self.assertEqual(result, 'Hello, Andrix!')
def test_views(self): load_settings('test_templates/settings.py') from ukumuku.views import View req = mock.Mock() resp = Response() view = View() view.get = mock.Mock() view.on_get(req, resp) view.get.assert_called_with(req) view.post = mock.Mock() view.on_post(req, resp) view.post.assert_called_with(req) view.put = mock.Mock() view.on_put(req, resp) view.put.assert_called_with(req) view.patch = mock.Mock() view.on_patch(req, resp) view.patch.assert_called_with(req) view.head = mock.Mock() view.on_head(req, resp) view.head.assert_called_with(req) view.delete = mock.Mock() view.on_delete(req, resp) view.delete.assert_called_with(req)
def test_template_response(self): load_settings('test_responses/settings.py') from ukumuku.responses import TemplateResponse template_response = TemplateResponse('index.html', {'name': 'Andrix'}) self.assertEqual(template_response.body, 'Hello, Andrix!')
def test_json_response(self): load_settings('test_responses/settings.py') from ukumuku.responses import JSONResponse json_response = JSONResponse({'count': 1}) self.assertEqual(json_response.body, '{"count": 1}')
def test_simple_http_response(self): load_settings('test_responses/settings.py') from ukumuku.responses import HttpResponse http_response = HttpResponse('hello!') self.assertEqual(http_response.body, 'hello!')
def test_simple_render_template(self): load_settings('test_templates/settings.py') from ukumuku.templates import template_engine result = template_engine.render_template('index.html', {'name' : 'Andrix'}) self.assertEqual(result, 'Hello, Andrix!')
def test_template_response(self): load_settings('test_responses/settings.py') from ukumuku.responses import TemplateResponse template_response = TemplateResponse('index.html', {'name' : 'Andrix'}) self.assertEqual(template_response.body, 'Hello, Andrix!')
def test_json_response(self): load_settings('test_responses/settings.py') from ukumuku.responses import JSONResponse json_response = JSONResponse({'count' : 1}) self.assertEqual(json_response.body, '{"count": 1}')