Browse files

fixed #6 and also bad tests

  • Loading branch information...
1 parent 49c7e11 commit e87aaa1518431d2ae8d1508a982881b99e4d4356 @keul keul committed Sep 3, 2012
View
3 docs/HISTORY.txt
@@ -10,8 +10,11 @@ Changelog
* adds events that call getThumb on the RemoteVideo adapter, and try to get a thumb image
for the video [micecchi, lucabel]
* fixed a GS circular dependency error [keul]
+* video size in content was ignored when also present in video metadata (close `#6`__)
+ [keul]
__ https://github.com/RedTurtle/redturtle.video/pull/8
+__ https://github.com/RedTurtle/redturtle.video/issues/6
0.7.3 (2012-05-18)
------------------
View
4 redturtle/video/README.txt
@@ -82,8 +82,8 @@ This is the page content.
>>> print browser.contents.strip()
<!DOCTYPE html...
...
- <div class="autoFlowPlayer video videoContent internalVideoContent" style="height: 480px; width: 640px;">
- <a class="videoWrapper" style="height: 480px; width: 640px;" href="http://.../rtinternalvideo-sample/at_download/file">
+ <div class="autoFlowPlayer video videoContent internalVideoContent" style="height: 300px; width: 400px;">
+ <a class="videoWrapper" style="height: 300px; width: 400px;" href="http://.../rtinternalvideo-sample/at_download/file">
...
</a>
</div>
View
2 redturtle/video/browser/video_view.pt
@@ -33,7 +33,7 @@
tal:attributes="href view/href;
style view/scale"
tal:define="scale context/@@images;
- thumbnail python: scale.scale('image', width=context.getWidth(), height=context.getHeight(), direction='down');
+ thumbnail python: scale.scale('image', width=context.getWidth() or view.width, height=context.getHeight() or view.height, direction='down');
showSplashImage python:thumbnail and context.hasSplashScreenImage() and context.getUseSplashScreen();">
<img tal:condition="showSplashImage"
alt="Video splashscreen"
View
5 redturtle/video/browser/view.py
@@ -48,9 +48,8 @@ class InternalVideo(File):
def __init__(self, context, request):
File.__init__(self, context, request)
-
- self.height = self.height or context.getHeight() or context.getDefaultHeight()
- self.width = self.width or context.getWidth() or context.getDefaultWidth()
+ self.height = context.getHeight() or self.height or context.getDefaultHeight()
+ self.width = context.getWidth() or self.width or context.getDefaultWidth()
self._scale = "height: %dpx; width: %dpx;" % (self.height, self.width)
def href(self):
View
3 redturtle/video/content/video_schema.py
@@ -33,8 +33,9 @@
validators = ('isTidyHtmlWithCleanup',),
default_output_type = 'text/x-html-safe',
widget = atapi.RichWidget(
- description = '',
label = _(u'label_body_text', default=u'Body Text'),
+ description = _(u'help_body_text',
+ default=u'You can use this field for provide a video transcript'),
rows = 25,
)),
View
10 redturtle/video/events.py
@@ -42,10 +42,12 @@ def _setVideoMetadata(object, name):
# size
try:
- width = metadata.getItems('width')[0].value
- height = metadata.getItems('height')[0].value
- object.setWidth(width)
- object.setHeight(height)
+ if not object.getWidth():
+ width = metadata.getItems('width')[0].value
+ object.setWidth(width)
+ if not object.getHeight():
+ object.setHeight(height)
+ height = metadata.getItems('height')[0].value
# no valid data
except ValueError:
pass
View
29 redturtle/video/tests/base.py
@@ -5,8 +5,10 @@
happens at module level, which makes it faster to run each test, but
slows down test runner startup.
"""
+
import os
import StringIO
+
from Products.Five import zcml
from Products.Five import fiveconfigure
@@ -15,10 +17,13 @@
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup
+import zope.component
from zope.publisher.interfaces.browser import IHTTPRequest
from zope.publisher.browser import TestRequest
from zope.interface import implements
+from redturtle.video.interfaces import IVideoEmbedCode, IRTRemoteVideo
+from redturtle.video.remote_thumb import RemoteThumb
@onsetup
def setup_product():
@@ -59,6 +64,19 @@ def setup_product():
ptc.setupPloneSite(products=['redturtle.video'])
+class TestVideoEmbedCode(object):
+ """test adapter for foo.com"""
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def getThumb(self):
+ return RemoteThumb(url='http://foo.com/image',
+ content_type='image/jpg',
+ filename='image.jpg')
+
+
class TestRequest(TestRequest):
implements(IHTTPRequest)
@@ -69,6 +87,17 @@ class TestCase(ptc.PloneTestCase):
applies to unit test cases.
"""
+ def setUp(self):
+ super(TestCase, self).setUp()
+ zope.component.provideAdapter(
+ TestVideoEmbedCode,
+ (IRTRemoteVideo,
+ zope.publisher.interfaces.browser.IHTTPRequest),
+ provides=IVideoEmbedCode,
+ name=u'foo.com'
+ )
+
+
def getVideoFile(self):
video = '/'.join(
os.path.realpath( __file__ ).split(os.path.sep)[:-2]
View
4 redturtle/video/tests/test_thumbnail_event.py
@@ -26,7 +26,7 @@ def test_no_image_provided(self):
id="remote-video-file")
f = getattr(self.portal, 'remote-video-file')
f.edit(title="A remote file",
- remoteUrl="http://youtu.be/KUKU0mq0fTU")
+ remoteUrl="http://foo.com/foo")
notify(ObjectInitializedEvent(f))
plone_italia_png = md5.new(self.image1.read()).digest()
img_from_video = md5.new(f.getImage().data).digest()
@@ -37,7 +37,7 @@ def test_image_provided(self):
id="other-remote-video-file")
f = getattr(self.portal, 'other-remote-video-file')
f.edit(title="Another remote file",
- remoteUrl="http://youtu.be/KUKU0mq0fTU",
+ remoteUrl="http://foo.com/foo",
image=self.image2.read(),
)
View
2 setup.py
@@ -51,7 +51,7 @@
zip_safe=False,
install_requires=install_requires,
tests_require=tests_require,
- extras_require=dict(tests=tests_require),
+ extras_require=dict(test=tests_require),
test_suite = 'redturtle.video.tests.test_doctest.test_suite',
entry_points="""
[z3c.autoinclude.plugin]

0 comments on commit e87aaa1

Please sign in to comment.