Example #1
0
    def setUp(self):
        self.video = make_video()
        self.u1 = UserFactory()
        self.u2 = UserFactory()
        self.anon = User.get_amara_anonymous()

        v = self.video
        self.en1 = pipeline.add_subtitles(v,
                                          'en',
                                          title="title 1",
                                          description="desc 1",
                                          subtitles=[(100, 200, "sub 1")],
                                          author=self.u1)
        self.en2 = pipeline.add_subtitles(v,
                                          'en',
                                          title="title 2",
                                          description="desc 2",
                                          subtitles=[(100, 200, "sub 2")],
                                          author=self.u2)
        self.en3 = pipeline.add_subtitles(v,
                                          'en',
                                          title="title 3",
                                          description="desc 3",
                                          subtitles=[(100, 200, "sub 3")],
                                          author=self.u1)
Example #2
0
    def test_author(self):
        def _get_tip_author():
            sl = SubtitleLanguage.objects.get(video=self.video,
                                              language_code='en')
            return sl.get_tip(full=True).author

        def _add(*args, **kwargs):
            pipeline.add_subtitles(self.video, 'en', None, *args, **kwargs)

        # Not passing at all.
        _add()
        self.assertEqual(_get_tip_author(), self.anon)

        # Passing nil.
        _add(author=None)
        self.assertEqual(_get_tip_author(), self.anon)

        # Passing anonymous.
        _add(author=User.get_amara_anonymous())
        self.assertEqual(_get_tip_author(), self.anon)

        # Passing u1.
        _add(author=self.u1)
        self.assertEqual(_get_tip_author().id, self.u1.id)

        # Passing u2.
        _add(author=self.u2)
        self.assertEqual(_get_tip_author().id, self.u2.id)

        # Passing nonsense
        self.assertRaises(ValueError, lambda: _add(author='dogs'))
        self.assertRaises(ValueError, lambda: _add(author=-1234))
        self.assertRaises(ValueError, lambda: _add(author=[self.u1]))
Example #3
0
 def setup_amara_db(self, db):
     from auth.models import CustomUser
     CustomUser.get_amara_anonymous()
Example #4
0
 def setUp(self):
     self.video = make_video()
     self.u1 = UserFactory()
     self.u2 = UserFactory()
     self.anon = User.get_amara_anonymous()
Example #5
0
def setup_amara_db(db):
    CustomUser.get_amara_anonymous()