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/03/11 19:46:13 UTC

git commit: fix test_macro_embed by stripping trailing ) and mocking the url fetch

Repository: incubator-allura
Updated Branches:
  refs/heads/master 17d9dc8c5 -> 03c8e4d20


fix test_macro_embed by stripping trailing ) and mocking the url fetch


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

Branch: refs/heads/master
Commit: 03c8e4d208ab93e13d206c69c2b4009c2b47d72d
Parents: 17d9dc8
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Mar 11 18:13:52 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Mar 11 18:13:52 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/macro.py          |  3 +++
 Allura/allura/tests/test_globals.py | 13 +++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/03c8e4d2/Allura/allura/lib/macro.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index 29181fb..80123de 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -401,6 +401,9 @@ def embed(url=None):
         html = None
 
     if html:
+        # youtube has a trailing ")" at the moment
+        html = html.rstrip(')')
+
         # convert iframe src from http to https, to avoid mixed security blocking when used on an https page
         html = BeautifulSoup(html)
         embed_url = html.find('iframe').get('src')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/03c8e4d2/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index d8f6b52..8a8410d 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -282,10 +282,19 @@ def test_macro_include_extra_br():
     assert html.strip().replace('\n', '') == expected_html, html
 
 
-def test_macro_embed():
+@patch('oembed.OEmbedEndpoint.fetch')
+def test_macro_embed(oembed_fetch):
+    oembed_fetch.return_value = {
+        "html": '<iframe width="480" height="270" src="http://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" frameborder="0" allowfullscreen></iframe>)',
+        "title": "Nature's 3D Printer: MIND BLOWING Cocoon in Rainforest - Smarter Every Day 94",
+    }
     r = g.markdown_wiki.convert(
         '[[embed url=http://www.youtube.com/watch?v=kOLpSPEA72U]]')
-    assert '''<div class="grid-20"><iframe height="270" src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" width="480"></iframe></div>''' in r
+    assert_in('<div class="grid-20"><iframe height="270" src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" width="480"></iframe></div>',
+              r)
+
+
+def test_macro_embed_notsupported():
     r = g.markdown_wiki.convert('[[embed url=http://vimeo.com/46163090]]')
     assert_equal(
         r, '<div class="markdown_content"><p>[[embed url=http://vimeo.com/46163090]]</p></div>')