コード例 #1
0
def test_deposit_vtt_tags(api_app, db, api_project, users):
    """Test VTT tag generation."""
    project, video_1, video_2 = api_project
    video_1_depid = video_1['_deposit']['id']

    # insert a master file inside the video
    add_master_to_video(
        video_deposit=video_1,
        filename='test.mp4',
        stream=BytesIO(b'1234'), video_duration="15"
    )
    # try to insert a new vtt object
    obj = ObjectVersion.create(
        video_1._bucket, key="test_fr.vtt",
        stream=BytesIO(b'hello'))
    # publish the video
    prepare_videos_for_publish([video_1])
    video_1 = deposit_video_resolver(video_1_depid)
    login_user(User.query.get(users[0]))
    video_1 = video_1.publish()

    # check tags
    check_object_tags(obj, video_1, content_type='vtt', media_type='subtitle',
                      context_type='subtitle', language='fr')

    # edit the video
    video_1 = video_1.edit()

    # try to delete the old vtt file and substitute with a new one
    video_1 = deposit_video_resolver(video_1_depid)
    ObjectVersion.delete(bucket=video_1._bucket, key=obj.key)
    obj2 = ObjectVersion.create(
        video_1._bucket, key="test_en.vtt", stream=BytesIO(b'hello'))

    # publish again the video
    video_1 = video_1.publish()

    # check tags
    check_object_tags(obj2, video_1, content_type='vtt', media_type='subtitle',
                      context_type='subtitle', language='en')

    # edit a re-published video
    video_1 = video_1.edit()

    # add a new vtt file
    obj3 = ObjectVersion.create(
        video_1._bucket, key="test_it.vtt", stream=BytesIO(b'hello'))

    # publish again the video
    video_1 = video_1.publish()

    # check tags
    check_object_tags(obj3, video_1, content_type='vtt', media_type='subtitle',
                      context_type='subtitle', language='it')
コード例 #2
0
def test_deposit_poster_tags(api_app, db, api_project, users):
    """Test poster tag generation."""
    project, video_1, video_2 = api_project
    video_1_depid = video_1['_deposit']['id']
    master_video_filename = 'test.mp4'
    poster_filename = 'poster.jpg'
    poster_filename2 = 'poster.png'

    # insert a master file inside the video
    add_master_to_video(video_deposit=video_1,
                        filename=master_video_filename,
                        stream=BytesIO(b'1234'),
                        video_duration='15')
    # try to insert a new vtt object
    obj = ObjectVersion.create(video_1._bucket,
                               key=poster_filename,
                               stream=BytesIO(b'hello'))
    # publish the video
    prepare_videos_for_publish([video_1])
    video_1 = deposit_video_resolver(video_1_depid)
    login_user(User.query.get(users[0]))
    video_1 = video_1.publish()

    # check tags
    check_object_tags(obj,
                      video_1,
                      content_type='jpg',
                      context_type='poster',
                      media_type='image')

    # edit the video
    video_1 = video_1.edit()

    # try to delete the old poster frame and substitute with a new one
    video_1 = deposit_video_resolver(video_1_depid)
    ObjectVersion.delete(bucket=video_1._bucket, key=obj.key)
    obj2 = ObjectVersion.create(video_1._bucket,
                                key=poster_filename2,
                                stream=BytesIO(b'hello'))

    # publish again the video
    video_1 = video_1.publish()

    # check tags
    check_object_tags(obj2,
                      video_1,
                      content_type='png',
                      context_type='poster',
                      media_type='image')
コード例 #3
0
def test_deposit_smil_tag_generation(api_app, db, api_project, users):
    """Test AVCWorkflow receiver."""
    def check_smil(video):
        _, record = video.fetch_published()
        master = CDSVideosFilesIterator.get_master_video_file(record)
        playlist = master['playlist']
        assert playlist[0]['key'] == '{}.smil'. \
                                     format(record['report_number'][0])
        assert playlist[0]['content_type'] == 'smil'
        assert playlist[0]['context_type'] == 'playlist'
        assert playlist[0]['media_type'] == 'text'
        assert playlist[0]['tags']['master'] == master['version_id']

        # check bucket dump is done correctly
        master_video = CDSVideosFilesIterator.get_master_video_file(video)
        assert master_video['version_id'] != master['version_id']

    project, video_1, video_2 = api_project
    video_1_depid = video_1['_deposit']['id']

    # insert a master file inside the video
    add_master_to_video(video_deposit=video_1,
                        filename='test.mp4',
                        stream=BytesIO(b'1234'),
                        video_duration="15s")
    # publish the video
    prepare_videos_for_publish([video_1])
    video_1 = deposit_video_resolver(video_1_depid)
    login_user(User.query.get(users[0]))
    video_1 = video_1.publish()

    # check smil
    check_smil(video_1)

    # edit the video
    video_1 = video_1.edit()

    # publish again the video
    video_1 = video_1.publish()

    # check smil
    check_smil(video_1)
コード例 #4
0
def test_video_name_after_publish(api_app, db, api_project, users):
    project, video_1, video_2 = api_project
    video_1_depid = video_1['_deposit']['id']
    master_video_filename = 'test.mp4'

    # insert a master file inside the video
    add_master_to_video(video_deposit=video_1,
                        filename=master_video_filename,
                        stream=BytesIO(b'1234'),
                        video_duration='15')

    # publish the video
    prepare_videos_for_publish([video_1])
    video_1 = deposit_video_resolver(video_1_depid)
    login_user(User.query.get(users[0]))
    video_1 = video_1.publish()

    _, record = video_1.fetch_published()
    master = CDSVideosFilesIterator.get_master_video_file(record)
    assert master['key'] == '{}.mp4'.format(record['report_number'][0])