Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
fix bug in test of encoding video
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitloup committed Jul 23, 2015
1 parent 6c07ca4 commit 215b180
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions pod_project/core/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,29 @@ class EncodingFileTestView(TestCase):
def setUp(self):
remi = User.objects.create(username="remi")
other_type = Type.objects.get(id=1)
url = "http://pod.univ-lille1.fr/media/pod.mp4"
tempfile = NamedTemporaryFile(delete=True)
HTTP_PROXY=getattr(settings, 'HTTP_PROXY', None)
if HTTP_PROXY:
proxy = urllib3.ProxyManager(settings.HTTP_PROXY)
with proxy.request('GET', url, preload_content=False) as r, open(tempfile.name, 'wb') as out_file:
shutil.copyfileobj(r, out_file)
else:
http = urllib3.PoolManager()
with http.request('GET', url, preload_content=False) as r, open(tempfile.name, 'wb') as out_file:
shutil.copyfileobj(r, out_file)
pod = Pod.objects.create(
type=other_type, title="Video", owner=remi, video="-", to_encode=False)
pod.video.save("test.mp4", File(tempfile))
file_path = os.path.join(settings.MEDIA_ROOT, 'videos', remi.username, 'test.mp4')
if not os.path.exists(file_path):
url = "http://pod.univ-lille1.fr/media/pod.mp4"
print "Download video file from %s" %url
tempfile = NamedTemporaryFile(delete=True)
HTTP_PROXY=getattr(settings, 'HTTP_PROXY', None)
if HTTP_PROXY:
proxy = urllib3.ProxyManager(settings.HTTP_PROXY)
with proxy.request('GET', url, preload_content=False) as r, open(tempfile.name, 'wb') as out_file:
shutil.copyfileobj(r, out_file)
else:
http = urllib3.PoolManager()
with http.request('GET', url, preload_content=False) as r, open(tempfile.name, 'wb') as out_file:
shutil.copyfileobj(r, out_file)
pod = Pod.objects.create(
type=other_type, title="Video", owner=remi, video="-", to_encode=False)
pod.video.save("test.mp4", File(tempfile))
else :
print "File already exist"
pod = Pod.objects.create(
type=other_type, title="Video", owner=remi, video="-", to_encode=False)
pod.video.name = os.path.join('videos', remi.username, 'test.mp4')
pod.save()
print "\n ---> SetUp of EncodingFileTestView : OK !"

def test_encoding(self):
Expand Down

0 comments on commit 215b180

Please sign in to comment.