def test_process_image_data_handles_example_dict():
    with open(os.path.join(RESOURCES, 'image_data_example.json')) as f:
        image_data = json.load(f)

    with patch.object(
            wmc.image_store,
            'add_item',
            return_value=1
    ) as mock_add:
        wmc._process_image_data(image_data)

    mock_add.assert_called_once_with(
        foreign_landing_url='https://commons.wikimedia.org/w/index.php?curid=81754323',
        image_url='https://upload.wikimedia.org/wikipedia/commons/2/25/20120925_PlozevetBretagne_LoneTree_DSC07971_PtrQs.jpg',
        license_url='https://creativecommons.org/licenses/by-sa/4.0',
        foreign_identifier=81754323,
        width=5514,
        height=3102,
        creator='PtrQs',
        creator_url='https://commons.wikimedia.org/wiki/User:PtrQs',
        title='File:20120925 PlozevetBretagne LoneTree DSC07971 PtrQs.jpg',
        meta_data={'description': 'SONY DSC', 'global_usage_count': 0,
                   'last_modified_at_source': '2019-09-01 00:38:47',
                   'date_originally_created': '2012-09-25 16:23:02'}
    )
Ejemplo n.º 2
0
def test_process_image_data_throws_out_invalid_mediatype(monkeypatch):
    image_data = {'mediatype': 'INVALID'}

    def mock_check_mediatype(image_info):
        return False

    monkeypatch.setattr(wmc, '_check_mediatype', mock_check_mediatype)
    with patch.object(wmc.image_store, 'add_item', return_value=1) as mock_add:
        wmc._process_image_data(image_data)

    mock_add.assert_not_called()
Ejemplo n.º 3
0
def test_process_image_data_handles_example_dict():
    with open(os.path.join(RESOURCES, 'image_data_example.json')) as f:
        image_data = json.load(f)

    with patch.object(wmc.image_store, 'add_item', return_value=1) as mock_add:
        wmc._process_image_data(image_data)

    mock_add.assert_called_once_with(
        foreign_landing_url=(
            'https://commons.wikimedia.org/w/index.php?curid=81754323'),
        image_url=(
            'https://upload.wikimedia.org/wikipedia/commons/2/25/20120925_'
            'PlozevetBretagne_LoneTree_DSC07971_PtrQs.jpg'),
        license_url='https://creativecommons.org/licenses/by-sa/4.0',
        foreign_identifier=81754323,
        width=5514,
        height=3102,
        creator='PtrQs',
        creator_url='https://commons.wikimedia.org/wiki/User:PtrQs',
        title='File:20120925 PlozevetBretagne LoneTree DSC07971 PtrQs.jpg',
        meta_data={
            'description':
            'SONY DSC',
            'global_usage_count':
            0,
            'last_modified_at_source':
            '2019-09-01 00:38:47',
            'date_originally_created':
            '2012-09-25 16:23:02',
            'categories': [
                'Coasts of Ploz\u00e9vet', 'No QIC by usr:PtrQs',
                ('Photographs taken with Minolta AF Zoom '
                 '28-70mm F2.8 G'), 'Self-published work',
                'Taken with Sony DSLR-A900', 'Trees in Finist\u00e8re'
            ]
        })