Exemple #1
0
def test_afs_url_handles_unicode():
    expected = u'file:///afs/cern.ch/project/inspire/PROD/var/data/files/g70/1407585/%E7%89%A9%E7%90%86%E7%A7%91%E5%AD%A6%E4%B8%8E%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2-%E6%9D%8E%E5%A8%9C-200650218-%E5%AD%A6%E4%BD%8D%E7%BA%A7....pdf%3B1'
    result = afs_url(
        u'/opt/cds-invenio/var/data/files/g70/1407585/物理科学与技术学院-李娜-200650218-学位级....pdf;1'
    )

    assert expected == result
Exemple #2
0
def test_afs_url_with_afs_service_enabled_and_encodes_characters():
    config = {'LABS_AFS_HTTP_SERVICE': 'http://jessicajones.com/nested/nested'}

    with patch.dict(current_app.config, config):
        expected = 'http://jessicajones.com/nested/nested/var/file%20with%20spaces.txt'
        result = afs_url('/opt/cds-invenio/var/file with spaces.txt')

        assert expected == result
Exemple #3
0
def test_afs_url_with_custom_afs_path():
    config = {'LEGACY_AFS_PATH': '/custom/path/'}

    with patch.dict(current_app.config, config):
        expected = 'file:///custom/path/var/file.txt'
        result = afs_url('/opt/cds-invenio/var/file.txt')

        assert expected == result
Exemple #4
0
def test_afs_url_with_afs_service_enabled_with_trailing_slash_converts_afs_path():
    config = {'LABS_AFS_HTTP_SERVICE': 'http://jessicajones.com/nested/nested/'}

    with patch.dict(current_app.config, config):

        expected = 'http://jessicajones.com/nested/nested/var/file.txt'
        result = afs_url('/opt/cds-invenio/var/file.txt')

        assert expected == result
Exemple #5
0
def test_afs_url_handles_none():
    expected = None
    result = afs_url(None)

    assert expected == result
Exemple #6
0
def test_afs_url_encodes_characters():
    expected = 'file:///afs/cern.ch/project/inspire/PROD/var/file%20with%20spaces.txt'
    result = afs_url('/opt/cds-invenio/var/file with spaces.txt')

    assert expected == result
Exemple #7
0
def test_afs_url_converts_afs_path():
    expected = 'file:///afs/cern.ch/project/inspire/PROD/var/file.txt'
    result = afs_url('/opt/cds-invenio/var/file.txt')

    assert expected == result
Exemple #8
0
def test_afs_url_ignores_non_afs_path():
    expected = 'http://example.com/file.pdf'
    result = afs_url('http://example.com/file.pdf')

    assert expected == result