You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/07/08 18:41:14 UTC

git commit: [#7528] set alphabetical HTML attributes for consistent test runs

Repository: allura
Updated Branches:
  refs/heads/master 4e9c46613 -> 1851fd746


[#7528] set alphabetical HTML attributes for consistent test runs


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1851fd74
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1851fd74
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1851fd74

Branch: refs/heads/master
Commit: 1851fd746efa941ba2d55e77e067e874e165c5e1
Parents: 4e9c466
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Jul 8 16:41:05 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Jul 8 16:41:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py          |  4 +++-
 Allura/allura/tests/functional/test_root.py       |  2 +-
 Allura/allura/tests/test_globals.py               | 18 +++++++++---------
 ForgeBlog/forgeblog/tests/test_commands.py        |  8 ++++----
 ForgeBlog/forgeblog/tests/unit/test_blog_post.py  |  2 +-
 .../forgetracker/tests/functional/test_root.py    |  6 +++---
 6 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 0eaf741..d2922c5 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -23,6 +23,7 @@ from tg import config
 from BeautifulSoup import BeautifulSoup
 import html5lib
 import html5lib.serializer
+import html5lib.filters.alphabeticalattributes
 import markdown
 
 from . import macro
@@ -509,7 +510,8 @@ class HTMLSanitizer(markdown.postprocessors.Postprocessor):
         parsed = parser.parse(text)
         serializer = html5lib.serializer.HTMLSerializer()
         walker = html5lib.getTreeWalker("etree")
-        out = ''.join(serializer.serialize(walker(parsed)))
+        stream = html5lib.filters.alphabeticalattributes.Filter(walker(parsed))
+        out = ''.join(serializer.serialize(stream))
         return out
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/Allura/allura/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 9681d61..179f19a 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -149,7 +149,7 @@ class TestRootController(TestController):
         n = M.Neighborhood.query.get(name='Projects')
         r = self.app.get(
             '/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True)
-        assert '<p><em>aaa</em>bb<a href="/p/test/wiki/Home/" class="alink">[wiki:Home]</a></p>' in r, r
+        assert '<p><em>aaa</em>bb<a class="alink" href="/p/test/wiki/Home">[wiki:Home]</a></p>' in r, r
 
     def test_slash_redirect(self):
         self.app.get('/p', status=301)

http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 702e037..5dc0e43 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -167,7 +167,7 @@ def test_macro_gittip_button():
     with h.push_config(c, project=p_test):
         r = g.markdown_wiki.convert('[[gittip_button username=test]]')
     assert_equal(
-        r, u'<div class="markdown_content"><p><iframe width="48pt" height="22pt" style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/test/widget.html"></iframe>\n</p></div>')
+        r, u'<div class="markdown_content"><p><iframe height="22pt" src="https://www.gittip.com/test/widget.html" style="border: 0; margin: 0; padding: 0;" width="48pt"></iframe>\n</p></div>')
 
 
 def test_macro_neighborhood_feeds():
@@ -325,7 +325,7 @@ def test_macro_embed(oembed_fetch):
     }
     r = g.markdown_wiki.convert(
         '[[embed url=http://www.youtube.com/watch?v=kOLpSPEA72U]]')
-    assert_in('<div class="grid-20"><iframe src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" height="270" width="480"></iframe>\n</div>',
+    assert_in('<div class="grid-20"><iframe height="270" src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" width="480"></iframe>\n</div>',
               r)
 
 
@@ -356,25 +356,25 @@ def test_wiki_artifact_links():
     assert 'See <span>[18:13:49]</span>' in text, text
     with h.push_context('test', 'wiki', neighborhood='Projects'):
         text = g.markdown.convert('Read [here](Home) about our project')
-        assert '<a href="/p/test/wiki/Home/" class="">here</a>' in text, text
+        assert '<a class="" href="/p/test/wiki/Home">here</a>' in text, text
         text = g.markdown.convert('[Go home](test:wiki:Home)')
-        assert '<a href="/p/test/wiki/Home/" class="">Go home</a>' in text, text
+        assert '<a class="" href="/p/test/wiki/Home">Go home</a>' in text, text
         text = g.markdown.convert('See [test:wiki:Home]')
-        assert '<a href="/p/test/wiki/Home/" class="alink">[test:wiki:Home]</a>' in text, text
+        assert '<a class="alink" href="/p/test/wiki/Home">[test:wiki:Home]</a>' in text, text
 
 
 def test_markdown_links():
     with patch.dict(tg.config, {'nofollow_exempt_domains': 'foobar.net'}):
         text = g.markdown.convert(
             'Read [here](http://foobar.net/) about our project')
-        assert_in('href="http://foobar.net/" class="">here</a> about', text)
+        assert_in('class="" href="http://foobar.net">here</a> about', text)
 
     text = g.markdown.convert(
         'Read [here](http://foobar.net/) about our project')
-    assert_in('href="http://foobar.net/" class="" rel="nofollow">here</a> about', text)
+    assert_in('class="" href="http://foobar.net" rel="nofollow">here</a> about', text)
 
     text = g.markdown.convert('Read [here](/p/foobar/blah) about our project')
-    assert_in('href="/p/foobar/blah" class="">here</a> about', text)
+    assert_in('class="" href="/p/foobar/blah">here</a> about', text)
 
     text = g.markdown.convert('Read <http://foobar.net/> about our project')
     assert_in(
@@ -412,7 +412,7 @@ def test_markdown_big_text():
 def test_markdown_basics():
     with h.push_context('test', 'wiki', neighborhood='Projects'):
         text = g.markdown.convert('# Foo!\n[Home]')
-        assert '<a href="/p/test/wiki/Home/" class="alink">[Home]</a>' in text, text
+        assert '<a class="alink" href="/p/test/wiki/Home">[Home]</a>' in text, text
         text = g.markdown.convert('# Foo!\n[Rooted]')
         assert '<a href=' not in text, text
 

http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/ForgeBlog/forgeblog/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_commands.py b/ForgeBlog/forgeblog/tests/test_commands.py
index b0cd2b4..7f2d0f7 100644
--- a/ForgeBlog/forgeblog/tests/test_commands.py
+++ b/ForgeBlog/forgeblog/tests/test_commands.py
@@ -149,8 +149,8 @@ def test_plaintext_preprocessor():
     html = g.markdown.convert(text)
     assert_equal(html,
                  '<div class="markdown_content"><p>1. foo '
-                 '#foo bar <a href="../baz" class="">baz</a> foo bar '
-                 '#foo bar <a href="../baz" class=""> baz </a></p></div>'
+                 '#foo bar <a class="" href="../baz">baz</a> foo bar '
+                 '#foo bar <a class="" href="../baz"> baz </a></p></div>'
                  )
 
 
@@ -172,6 +172,6 @@ def test_plaintext_preprocessor_wrapped():
     html = g.markdown.convert(text)
     assert_equal(html,
                  '<div class="markdown_content"><p>1. foo</p>\n'
-                 '<p>#foo bar <a href="../baz" class="">baz</a> foo bar </p>\n'
-                 '<p>#foo bar <a href="../baz" class=""> baz </a></p></div>'
+                 '<p>#foo bar <a class="" href="../baz">baz</a> foo bar </p>\n'
+                 '<p>#foo bar <a class="" href="../baz"> baz </a></p></div>'
                  )

http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
index 4d0b740..34842c5 100644
--- a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
+++ b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
@@ -132,6 +132,6 @@ class TestHtmlPreview(BlogTestWithModel):
                     'fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
                     'non proident, sunt in culpa qui officia deserunt mollit '
                     'anim id est laborum.... '
-                    '<a href="/p/test/blog/%s/%02i/untitled/" class="">'
+                    '<a class="" href="/p/test/blog/%s/%02i/untitled">'
                     'read more</a></p></div>') % (now.year, now.month)
         assert_equal(self._make_post(text).html_text_preview, expected)

http://git-wip-us.apache.org/repos/asf/allura/blob/1851fd74/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 7c9fffe..890029a 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -891,8 +891,8 @@ class TestFunctionalController(TrackerTestController):
         assert_not_in('Tickets: <s>#1</s>', r)
         assert_in('Tickets: <s>#2</s>', r)
 
-        assert_in('<a href="/p/test/bugs/1/" class="alink">[#1]</a>', r.body)
-        assert_in('<a href="/p/test/bugs/2/" class="alink strikethrough">[#2]</a>', r.body)
+        assert_in('<a class="alink" href="/p/test/bugs/1">[#1]</a>', r.body)
+        assert_in('<a class="alink strikethrough" href="/p/test/bugs/2">[#2]</a>', r.body)
 
     def test_ticket_view_editable(self):
         summary = 'test ticket view page can be edited'
@@ -2324,7 +2324,7 @@ class TestFunctionalController(TrackerTestController):
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
             assert 'Subject: [test:bugs] #1 test <h2> ticket' in body
-            assert '<p><strong> <a href="http://localhost/p/test/bugs/1/" class="alink">[bugs:#1]</a> test &lt;h2&gt; ticket</strong></p>' in body
+            assert '<p><strong> <a class="alink" href="http://localhost/p/test/bugs/1">[bugs:#1]</a> test &lt;h2&gt; ticket</strong></p>' in body
 
     @patch('forgetracker.search.query_filter_choices')
     def test_multiselect(self, query_filter_choices):