def test_output_in_templates(self): approx_count = Author.objects.approx_count(min_size=1) text = Template("{{ var }}").render(Context({"var": approx_count})) assert text.startswith("Approximately ") approx_count2 = Author.objects.approx_count(min_size=1, return_approx_int=False) text = Template("{{ var }}").render(Context({"var": approx_count2})) assert not text.startswith("Approximately ")
def test_output_in_templates(self): approx_count = Author.objects.approx_count(min_size=1) text = Template('{{ var }}').render(Context({'var': approx_count})) assert text.startswith('Approximately ') approx_count2 = Author.objects.approx_count( min_size=1, return_approx_int=False, ) text = Template('{{ var }}').render(Context({'var': approx_count2})) assert not text.startswith('Approximately ')
def test_output_in_templates(self): approx_count = Author.objects.approx_count(min_size=1) text = Template('{{ var }}').render(Context({'var': approx_count})) self.assertTrue(text.startswith('Approximately ')) approx_count2 = Author.objects.approx_count( min_size=1, return_approx_int=False ) text = Template('{{ var }}').render(Context({'var': approx_count2})) self.assertFalse(text.startswith('Approximately '))
def test_markdown_comment(self): user = User.objects.create_user("user", "*****@*****.**", password="******") topic = TestModel.objects.create(name="Test2") markdown_txt = """ A First Level Header ==================== A Second Level Header --------------------- Now is the time for all good men to come to the aid of their country. This is just a regular paragraph. The quick brown fox jumped over the lazy dog's back. ### Header 3 > This is a blockquote. > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote """ comment_markdown = ThreadedComment.objects.create_for_object( topic, user=user, ip_address="127.0.0.1", markup=MARKDOWN, comment=markdown_txt ) c = Context({"comment": comment_markdown}) s = Template("{% load threadedcommentstags %}{% auto_transform_markup comment %}").render(c).replace("\\n", "") self.assertEquals(s.startswith(u"<h1>"), True)
def test_data_script_is_included(self): out = Template( "{% load react %}" "{% react_render component=\"Component\" identifier=\"my_id\" %}" "{% react_print %}").render(self.mocked_context) self.assertFalse( out.startswith('<script id="my_id_data" type="application/json"'))
def test_no_placeholder_returns_nothing(self): out = Template( "{% load react %}" "{% react_render component=\"Component\" prop_country=\"Sweden\" no_placeholder=1 %}" "{% react_print %}").render(self.mocked_context) self.assertFalse(out.startswith('<div id="Component_')) self.assertTrue('{\"country\": \"Sweden\"}' in out)
def test_only_ssr_html_are_returned_on_no_placeholder(self, mocked): mocked.side_effect = [ MockResponse( mock_hypernova_success_response('Foo Bar'), 200, ) ] out = Template( "{% load react %}" "{% react_render component=\"Component\" no_placeholder=1 %}" ).render(self.mocked_context) queue = self.mocked_context["REACT_COMPONENTS"] self.assertTrue(len(queue), 1) self.assertFalse(out.startswith('<div id="Component_'))
def test_rest_comment(self): user = User.objects.create_user('user', '*****@*****.**', password='******') topic = TestModel.objects.create(name="Test2") rest_txt = ''' FooBar Header ============= reStructuredText is **nice**. It has its own webpage_. A table: ===== ===== ====== Inputs Output ------------ ------ A B A or B ===== ===== ====== False False False True False True False True True True True True ===== ===== ====== RST TracLinks ------------- See also ticket `#42`::. .. _webpage: http://docutils.sourceforge.net/rst.html ''' comment_rest = ThreadedComment.objects.create_for_object( topic, user=user, ip_address='127.0.0.1', markup=REST, comment=rest_txt, ) c = Context({'comment': comment_rest}) s = Template( "{% load threadedcommentstags %}{% auto_transform_markup comment %}" ).render(c) self.assertEquals(s.startswith('<p>reStructuredText is'), True)
def test_markdown_comment(self): user = User.objects.create_user('user', '*****@*****.**', password='******') topic = TestModel.objects.create(name="Test2") markdown_txt = ''' A First Level Header ==================== A Second Level Header --------------------- Now is the time for all good men to come to the aid of their country. This is just a regular paragraph. The quick brown fox jumped over the lazy dog's back. ### Header 3 > This is a blockquote. > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote ''' comment_markdown = ThreadedComment.objects.create_for_object( topic, user=user, ip_address='127.0.0.1', markup=MARKDOWN, comment=markdown_txt, ) c = Context({ 'comment': comment_markdown, }) s = Template( "{% load threadedcommentstags %}{% auto_transform_markup comment %}" ).render(c).replace('\\n', '') self.assertEquals(s.startswith(u"<h1>"), True)
def test_rest_comment(self): user = User.objects.create_user('user', '*****@*****.**', password='******') topic = TestModel.objects.create(name="Test2") rest_txt = ''' FooBar Header ============= reStructuredText is **nice**. It has its own webpage_. A table: ===== ===== ====== Inputs Output ------------ ------ A B A or B ===== ===== ====== False False False True False True False True True True True True ===== ===== ====== RST TracLinks ------------- See also ticket `#42`::. .. _webpage: http://docutils.sourceforge.net/rst.html ''' comment_rest = ThreadedComment.objects.create_for_object( topic, user = user, ip_address = '127.0.0.1', markup = REST, comment = rest_txt, ) c = Context({ 'comment': comment_rest }) s = Template("{% load threadedcommentstags %}{% auto_transform_markup comment %}").render(c) self.assertEquals(s.startswith('<p>reStructuredText is'), True)