Esempio n. 1
0
def test_record_build_url(api_app):
    """Test record build url."""
    assert 'https://cds.cern.ch/api/record/1' == record_build_url(1)
Esempio n. 2
0
def test_video_publish_and_edit(api_project, users):
    """Test video publish and edit."""
    (project, video_1, video_2) = api_project
    video_path_1 = project['videos'][0]['$ref']
    video_path_2 = project['videos'][1]['$ref']

    deposit_project_schema = (
        'https://cdslabs.cern.ch/schemas/'
        'deposits/records/videos/project/project-v1.0.0.json')
    deposit_video_schema = ('https://cdslabs.cern.ch/schemas/'
                            'deposits/records/videos/video/video-v1.0.0.json')
    record_video_schema = ('https://cdslabs.cern.ch/schemas/'
                           'records/videos/video/video-v1.0.0.json')

    # check video1 is not published
    assert video_1['_deposit']['status'] == 'draft'
    assert video_2['_deposit']['status'] == 'draft'
    assert project['_deposit']['status'] == 'draft'
    # and the schema is a deposit
    assert video_1['$schema'] == deposit_video_schema
    assert video_2['$schema'] == deposit_video_schema
    assert project['$schema'] == deposit_project_schema

    # update video

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

    project = video_1.project
    (_, record_video_1) = video_1.fetch_published()
    record_video_id_1 = record_video_1['recid']
    record_path_1 = record_build_url(record_video_id_1)

    # check new link project -> video
    assert video_1['_deposit']['status'] == 'published'
    assert video_2['_deposit']['status'] == 'draft'
    assert project['_deposit']['status'] == 'draft'
    # check the schema is a record
    assert record_video_1['$schema'] == record_video_schema
    assert video_2['$schema'] == deposit_video_schema
    assert project['$schema'] == deposit_project_schema
    # check video recid is inside the list
    assert any(video_ref['$ref'] == record_path_1
               for video_ref in project['videos']) is True
    # and there is not the old id (when the video was a deposit)
    assert any(video_ref['$ref'] == video_path_1
               for video_ref in project['videos']) is False
    # and still exists video 2 deposit id
    assert any(video_ref['$ref'] == video_path_2
               for video_ref in project['videos']) is True

    # [edit the video 1]
    video_1_v2 = record_video_resolver(
        record_video_1['_deposit']['pid']['value'])
    video_1_v2 = video_1_v2.edit()

    # check video1 is not published
    assert video_1_v2['_deposit']['status'] == 'draft'
    assert video_2['_deposit']['status'] == 'draft'
    assert project['_deposit']['status'] == 'draft'
    # check the schema is a record
    assert video_1_v2['$schema'] == deposit_video_schema
    assert video_2['$schema'] == deposit_video_schema
    assert project['$schema'] == deposit_project_schema
    # check video1 v1 recid is NOT inside the list
    assert any(video_ref['$ref'] == record_path_1
               for video_ref in project['videos']) is False
    # check video1 v2 is inside the list
    video_path_1_v2 = video_build_url(video_1_v2['_deposit']['id'])
    assert any(video_ref['$ref'] == video_path_1_v2
               for video_ref in project['videos']) is True
Esempio n. 3
0
def test_record_build_url(deposit_rest):
    """Test record build url."""
    assert '/record/1' == record_build_url(1)