Ejemplo n.º 1
0
    def test_as_HTML_should_not_append_charset_to_content_type_if_there_is_one(self, convert_mocked):
        # Arrange
        request = {}
        response = {'_meta': dict(status=200, message='OK')}
        content_type = 'text/html; charset=utf-8'
        convert_mocked.return_value = 'text'

        # Act
        response = build_html(request, response, content_type)

        # Assert
        self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8')
Ejemplo n.º 2
0
    def test_as_HTML_should_call_convert (self, convert_mocked):
        # Arrange
        request = {}
        response = {'_meta': dict(status=200, message='OK')}
        content_type = None
        convert_mocked.return_value = 'text'
        expected_html_response = BeautifulSoup(self.html_template % convert_mocked.return_value).prettify()

        # Act
        response = build_html(request, response, content_type)

        # Assert
        self.assertTrue(convert_mocked.called)

        self.assertEqual(response.content, expected_html_response)