@@ -0,0 +1,2991 @@
+# -*- coding: utf-8 -*-%0A# Amara, universalsubtitles.org%0A#%0A# Copyright (C) 2012 Participatory Culture Foundation%0A#%0A# This program is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU Affero General Public License as%0A# published by the Free Software Foundation, either version 3 of the%0A# License, or (at your option) any later version.%0A#%0A# This program is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the%0A# GNU Affero General Public License for more details.%0A#%0A# You should have received a copy of the GNU Affero General Public License%0A# along with this program. If not, see%0A# http://www.gnu.org/licenses/agpl-3.0.html.%0A%22%22%22Data creation and retrieval functions for the video tests.%22%22%22%0A%0Afrom apps.auth.models import CustomUser as User%0Afrom apps.videos.models import Video%0Afrom apps.subtitles import pipeline%0Afrom apps.subtitles.models import SubtitleLanguage%0A%0A%0A# Normal Users ----------------------------------------------------------------%0Adef get_user(n=1):%0A    username = 'test_user_%25s' %25 n%0A    email = %22test_user_%25s@example.com%22 %25 n%0A    try:%0A        user = User.objects.get(username=username)%0A    except User.DoesNotExist:%0A        user = User.objects.create(%0A            username=username, email=email,%0A            is_active=True, is_superuser=False, is_staff=False,%0A            password=%22sha1$6b3dc$72c6a16f127d2c217f72009632c745effef7eb3f%22,%0A        )%0A    return user%0A%0A%0A# Site Admins -----------------------------------------------------------------%0Adef get_site_admin(n=1):%0A    username = 'test_admin_%25s' %25 n%0A    email = %22test_admin_%25s@example.com%22 %25 n%0A    try:%0A        user = User.objects.get(username=username)%0A    except User.DoesNotExist:%0A        user = User.objects.create(%0A            username=username, email=email,%0A            is_active=True, is_superuser=True, is_staff=True,%0A            password=%22sha1$6b3dc$72c6a16f127d2c217f72009632c745effef7eb3f%22,%0A        )%0A    return user%0A%0A%0A# Videos ----------------------------------------------------------------------%0AVIDEO_URLS = ('http://youtu.be/heKK95DAKms',%0A              'http://youtu.be/e4MSN6IImpI',%0A              'http://youtu.be/i_0DXxNeaQ0',)%0A%0Adef get_video(n=1, user=None):%0A    video, _ = Video.get_or_create_for_url(VIDEO_URLS%5Bn%5D, user=user)%0A    return video%0A%0A%0A# Subtitle Languages ----------------------------------------------------------%0Adef make_subtitle_language(video, language_code):%0A    sl = SubtitleLanguage(video=video, language_code=language_code)%0A    sl.save()%0A    return sl%0A%0A%0A# Subtitle Versions -----------------------------------------------------------%0Adef make_subtitle_version(subtitle_language, subtitles=%5B%5D, author=None):%0A    return pipeline.add_subtitles(subtitle_language.video,%0A                                  subtitle_language.language_code,%0A                                  subtitles,%0A                                  author=author)%0A

Add a file with video test data creation functions.