Пример #1
0
 def test_render_text_converts_links(self):
     schema = self.schema_skeleton
     schema['template_text'] = "link to http://www.findeco.de"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, 'link to '
                                    '<a href="http://www.findeco.de">'
                                    'http://www.findeco.de</a>')
Пример #2
0
 def test_render_text_inserts_links_for_hash_tags(self):
     schema = self.schema_skeleton
     schema['template_text'] = "link to #hash #tag"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, 'link to '
                                    '<a href="/search/hash">#hash</a> '
                                    '<a href="/search/tag">#tag</a>')
Пример #3
0
 def test_render_text_inserts_links_for_hash_tags(self):
     schema = self.schema_skeleton
     schema['template_text'] = "link to #hash #tag"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(
         p.text_cache, 'link to '
         '<a href="/search/hash">#hash</a> '
         '<a href="/search/tag">#tag</a>')
Пример #4
0
 def test_render_text_converts_links(self):
     schema = self.schema_skeleton
     schema['template_text'] = "link to http://www.findeco.de"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(
         p.text_cache, 'link to '
         '<a href="http://www.findeco.de">'
         'http://www.findeco.de</a>')
Пример #5
0
 def test_render_text_inserts_node_references(self):
     schema = self.schema_skeleton
     schema['template_text'] = "reference nodes {n0}, {n1} and {n0} again."
     schema['references'] = [self.foo1, self.foo1bar1]
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, 'reference nodes '
                                    '<a href="/foo.1">foo_long<span class="nodeIndex">1</span></a>, '
                                    '<a href="/foo.1/bar.1">bar_long<span class="nodeIndex">1</span></a> '
                                    'and <a href="/foo.1">foo_long<span class="nodeIndex">1</span></a> '
                                    'again.')
Пример #6
0
 def test_render_text_inserts_mentions(self):
     schema = self.schema_skeleton
     schema['template_text'] = "reference users {u0}, {u1} and {u0} again."
     schema['mentions'] = [self.hugo, self.herbert]
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, 'reference users '
                                    '<a href="/user/hugo">@hugo</a>, '
                                    '<a href="/user/herbert">@herbert</a> '
                                    'and <a href="/user/hugo">@hugo</a> '
                                    'again.')
Пример #7
0
 def test_render_text_inserts_node_references(self):
     schema = self.schema_skeleton
     schema['template_text'] = "reference nodes {n0}, {n1} and {n0} again."
     schema['references'] = [self.foo1, self.foo1bar1]
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(
         p.text_cache, 'reference nodes '
         '<a href="/foo.1">foo_long<span class="nodeIndex">1</span></a>, '
         '<a href="/foo.1/bar.1">bar_long<span class="nodeIndex">1</span></a> '
         'and <a href="/foo.1">foo_long<span class="nodeIndex">1</span></a> '
         'again.')
Пример #8
0
 def test_render_text_inserts_mentions(self):
     schema = self.schema_skeleton
     schema['template_text'] = "reference users {u0}, {u1} and {u0} again."
     schema['mentions'] = [self.hugo, self.herbert]
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(
         p.text_cache, 'reference users '
         '<a href="/user/hugo">@hugo</a>, '
         '<a href="/user/herbert">@herbert</a> '
         'and <a href="/user/hugo">@hugo</a> '
         'again.')
Пример #9
0
    def test_create_post_adds_many_to_many_relations(self):
        hugo = create_user('hugo')
        herbert = create_user('herbert')

        foo = create_nodes_for_path('foo.1')
        bar = create_nodes_for_path('bar.1')

        schema = {
            'author': hugo.id,
            'location': foo.id,
            'type': "userpost",
            'template_text': "reference to {u0} and {u1} and {n0} and {n1}",
            'mentions': [hugo, herbert],
            'references': [foo, bar],
            'answer_to': None
        }

        p = create_post_from_schema(schema)
        p_db = Post.objects.get(id=p.id)
        self.assertEqual(p.author, p_db.author)
        self.assertEqual(p.post_type, p_db.post_type)
        self.assertListEqual(list(p.mentions.all()), list(p_db.mentions.all()))
        self.assertListEqual(list(p.node_references.all()), list(p_db.node_references.all()))
Пример #10
0
    def test_create_post_adds_many_to_many_relations(self):
        hugo = create_user('hugo')
        herbert = create_user('herbert')

        foo = create_nodes_for_path('foo.1')
        bar = create_nodes_for_path('bar.1')

        schema = {
            'author': hugo.id,
            'location': foo.id,
            'type': "userpost",
            'template_text': "reference to {u0} and {u1} and {n0} and {n1}",
            'mentions': [hugo, herbert],
            'references': [foo, bar],
            'answer_to': None
        }

        p = create_post_from_schema(schema)
        p_db = Post.objects.get(id=p.id)
        self.assertEqual(p.author, p_db.author)
        self.assertEqual(p.post_type, p_db.post_type)
        self.assertListEqual(list(p.mentions.all()), list(p_db.mentions.all()))
        self.assertListEqual(list(p.node_references.all()),
                             list(p_db.node_references.all()))
Пример #11
0
 def test_render_text_escapes_html(self):
     schema = self.schema_skeleton
     schema['template_text'] = "<script> evil </script>"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, "&lt;script&gt; evil &lt;/script&gt;")
Пример #12
0
 def test_render_text_generates_text(self):
     schema = self.schema_skeleton
     schema['template_text'] = "text without special stuff"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, "text without special stuff")
Пример #13
0
 def test_render_text_escapes_html(self):
     schema = self.schema_skeleton
     schema['template_text'] = "<script> evil </script>"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, "&lt;script&gt; evil &lt;/script&gt;")
Пример #14
0
 def test_render_text_generates_text(self):
     schema = self.schema_skeleton
     schema['template_text'] = "text without special stuff"
     p = create_post_from_schema(schema)
     p.render()
     self.assertEqual(p.text_cache, "text without special stuff")