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

Commit

Permalink
Merge pull request #54 from SemmLille/ptitloup/bugfix-es_test_install
Browse files Browse the repository at this point in the history
Ptitloup/bugfix es test install
  • Loading branch information
ptitloup committed Jul 23, 2015
2 parents 66f8f64 + 5c59f3d commit d1c61b9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
41 changes: 25 additions & 16 deletions pod_project/core/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ def setUp(self):
print "EsTestView"

def test_es(self):
es_url = settings.HAYSTACK_CONNECTIONS['default']['URL']
es_url = getattr(settings, 'ES_URL', ['http://127.0.0.1:9200/'])
print "> Elastic search url : %s " % es_url
http = urllib3.PoolManager()
r = http.request('GET', es_url)
r = http.request('GET', es_url[0])
self.assertEqual(r.status, 200)
print "\n ---> test_es of EsTestView : OK ! \n info : \n %s \n" % r.data

Expand All @@ -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
1 change: 1 addition & 0 deletions pod_project/pod_project/settings-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'taggit',
'taggit_templatetags',
'jquery',
'djangoformsetjs',
'captcha',
'bootstrap3',
# Applications locales
Expand Down
7 changes: 5 additions & 2 deletions pod_project/pods/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,14 @@ class ReportVideoTestCase(TestCase):

def setUp(self):
remi = User.objects.create_user("Remi")
nicolas = User.objects.create_user("Nicolas")
other_type = Type.objects.get(id=1)
pod = Pod.objects.create(
type=other_type, title="Video1", slug="tralala", owner=remi)

ReportVideo.objects.create(video=pod, user=remi)
ReportVideo.objects.create(video=pod, user=remi, comment="violation des droits", answer="accepte")

ReportVideo.objects.create(video=pod, user=nicolas, comment="violation des droits", answer="accepte")


print (" ---> SetUp of ReportVideoTestCase : OK !")
Expand Down Expand Up @@ -797,7 +800,7 @@ def test_attributs_with_comment(self):
self.assertEqual(reportVideo.video.id, 1)
self.assertEqual(reportVideo.__unicode__(), "%s - %s" %
(reportVideo.video, reportVideo.user))
self.assertEqual(reportVideo.user.username, "Remi")
self.assertEqual(reportVideo.user.username, "Nicolas")
date = datetime.today()
self.assertEqual(reportVideo.date_added.year, date.year)
self.assertEqual(reportVideo.date_added.month, date.month)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ django-bootstrap3==3.2.1
django-ckeditor-updated==4.4.4
django-extensions==1.3.3
django-filer==0.9.10
django-formset-js==0.4.0
django-jquery-js==2.1.4
django-modeltranslation==0.8
django-mptt==0.6.1
Expand Down

0 comments on commit d1c61b9

Please sign in to comment.