Ejemplo n.º 1
0
        def test_create_and_update_video(self):
            cat = category(save=True)
            lang = language(name=u'English 2', save=True)

            ret = richardapi.create_video(
                self.api_url,
                auth_token=self.token.key,
                video_data={
                    'title': 'Test video create and update',
                    'language': lang.name,
                    'category': cat.title,
                    'state': richardapi.STATE_DRAFT,
                    'speakers': ['Jimmy'],
                    'tags': ['foo'],
                })

            video = Video.objects.get(title='Test video create and update')

            eq_(video.title, ret['title'])
            eq_(video.state, ret['state'])
            eq_(video.id, ret['id'])

            ret['title'] = 'Video Test'
            ret = richardapi.update_video(
                self.api_url,
                auth_token=self.token.key,
                video_id=ret['id'],
                video_data=ret
            )

            video = Video.objects.get(title='Video Test')
            eq_(video.title, ret['title'])
        def test_create_and_update_video(self):
            cat = factories.CategoryFactory()
            lang = factories.LanguageFactory(name=u'English 2')

            ret = richardapi.create_video(
                self.api_url,
                auth_token=self.token.key,
                video_data={
                    'title': 'Test video create and update',
                    'language': lang.name,
                    'category': cat.title,
                    'state': richardapi.STATE_DRAFT,
                    'speakers': ['Jimmy'],
                    'tags': ['foo'],
                })

            video = Video.objects.get(title='Test video create and update')

            assert video.title == ret['title']
            assert video.state == ret['state']
            assert video.id == ret['id']

            ret['title'] = 'Video Test'
            ret = richardapi.update_video(
                self.api_url,
                auth_token=self.token.key,
                video_id=ret['id'],
                video_data=ret
            )

            video = Video.objects.get(title='Video Test')
            assert video.title == ret['title']
Ejemplo n.º 3
0
        def test_create_and_update_video(self):
            cat = category(save=True)
            lang = language(name=u'English', save=True)

            ret = richardapi.create_video(
                self.api_url,
                auth_token=self.token.key,
                video_data={
                    'title': 'Test video',
                    'language': lang.name,
                    'category': cat.title,
                    'state': 2,  # Has to be draft so update works
                    'speakers': ['Jimmy'],
                    'tags': ['foo'],
                })

            video = Video.objects.get(title='Test video')

            eq_(video.title, ret['title'])
            eq_(video.state, ret['state'])
            eq_(video.id, ret['id'])

            ret['title'] = 'Video Test'
            ret = richardapi.update_video(self.api_url,
                                          auth_token=self.token.key,
                                          video_id=ret['id'],
                                          video_data=ret)

            video = Video.objects.get(title='Video Test')
            eq_(video.title, ret['title'])
Ejemplo n.º 4
0
    def create_pyvideo(self, video_data):
        """ creates a pyvideo record
        :arg video_data: dict of video information to be added

        :returns: a pyvideo url for the video

        """
        try:
            video_data['added'] = datetime.datetime.now().isoformat()
            vid = create_video(self.pyvideo_endpoint, self.host['user'], self.host['api_key'], video_data)
            return 'http://%s/video/%s/%s' % (self.host['host'], vid['id'],vid['slug'])
        except MissingRequiredData as e:
            print '#3, Missing required fields', e.errors
            raise e
Ejemplo n.º 5
0
    def create_richard(self, video_data):
        """ creates a richard record
        :arg video_data: dict of video information to be added

        :returns: a richard url for the video

        """
        try:
            vid = create_video(self.richard_endpoint, self.host["api_key"], video_data)
            url = "http://%s/video/%s/%s" % (self.host["host"], vid["id"], vid["slug"])
            return url

        except MissingRequiredData as e:
            print "#3, Missing required fields", e
            raise e
        except Http4xxException as exc:
            print exc.response.status_code
            print exc.response.content
Ejemplo n.º 6
0
    def create_richard(self, video_data):
        """ creates a richard record
        :arg video_data: dict of video information to be added

        :returns: a richard url for the video

        """
        try:
            vid = create_video(self.richard_endpoint,
                    self.host['api_key'], video_data)
            url = 'http://%s/video/%s/%s' % (
                    self.host['host'], vid['id'],vid['slug'])
            return url

        except MissingRequiredData as e:
            print('#3, Missing required fields', e)
            raise e
        except Http4xxException as exc:
            print(exc.response.status_code)
            print(exc.response.content)
Ejemplo n.º 7
0
    def create_richard(self, video_data):
        """ creates a richard record
        :arg video_data: dict of video information to be added

        :returns: a richard url for the video

        """
        try:
            vid = create_video(self.richard_endpoint, 
                    self.host['api_key'], video_data)
            url = 'http://%s/video/%s/%s' % (
                    self.host['host'], vid['id'],vid['slug'])
            return url

        except MissingRequiredData as e:
            print('#3, Missing required fields', e)
            raise e
        except Http4xxException as exc:
            print(exc.response.status_code)
            print(exc.response.content)
Ejemplo n.º 8
0
        def test_create_and_get_video(self):
            cat = factories.CategoryFactory()
            lang = factories.LanguageFactory(name=u'English 1')

            ret = richardapi.create_video(self.api_url,
                                          auth_token=self.token.key,
                                          video_data={
                                              'title':
                                              'Test video create and get',
                                              'language': lang.name,
                                              'category': cat.title,
                                              'state': richardapi.STATE_DRAFT,
                                              'speakers': ['Jimmy'],
                                              'tags': ['foo'],
                                          })

            vid = richardapi.get_video(self.api_url,
                                       auth_token=self.token.key,
                                       video_id=ret['id'])
            assert vid['id'] == ret['id']
            assert vid['title'] == ret['title']
Ejemplo n.º 9
0
        def test_create_and_get_video(self):
            cat = category(save=True)
            lang = language(name=u'English 1', save=True)

            ret = richardapi.create_video(self.api_url,
                                          auth_token=self.token.key,
                                          video_data={
                                              'title':
                                              'Test video create and get',
                                              'language': lang.name,
                                              'category': cat.title,
                                              'state': richardapi.STATE_DRAFT,
                                              'speakers': ['Jimmy'],
                                              'tags': ['foo'],
                                          })

            vid = richardapi.get_video(self.api_url,
                                       auth_token=self.token.key,
                                       video_id=ret['id'])
            eq_(vid['id'], ret['id'])
            eq_(vid['title'], ret['title'])
Ejemplo n.º 10
0
        def test_create_and_get_video(self):
            cat = category(save=True)
            lang = language(name=u'English 1', save=True)

            ret = richardapi.create_video(
                self.api_url,
                auth_token=self.token.key,
                video_data={
                    'title': 'Test video create and get',
                    'language': lang.name,
                    'category': cat.title,
                    'state': richardapi.STATE_DRAFT,
                    'speakers': ['Jimmy'],
                    'tags': ['foo'],
                })

            vid = richardapi.get_video(
                self.api_url,
                auth_token=self.token.key,
                video_id=ret['id'])
            eq_(vid['id'], ret['id'])
            eq_(vid['title'], ret['title'])
Ejemplo n.º 11
0
        def test_create_and_get_video(self):
            cat = factories.CategoryFactory()
            lang = factories.LanguageFactory(name=u'English 1')

            ret = richardapi.create_video(
                self.api_url,
                auth_token=self.token.key,
                video_data={
                    'title': 'Test video create and get',
                    'language': lang.name,
                    'category': cat.title,
                    'state': richardapi.STATE_DRAFT,
                    'speakers': ['Jimmy'],
                    'tags': ['foo'],
                })

            vid = richardapi.get_video(
                self.api_url,
                auth_token=self.token.key,
                video_id=ret['id'])
            assert vid['id'] == ret['id']
            assert vid['title'] == ret['title']