Exemplo n.º 1
0
def test_run_bad_request(monkeypatch, config_obj, errmsg):
    def raise_function(*a, **kw):
        raise IOError()
    monkeypatch.setattr('requests.get', raise_function)
    monkeypatch.setattr('flickrapi.FlickrAPI.walk',
                        lambda self, **kw: [{'id': 1}])
    monkeypatch.setattr('walls.smallest_url', lambda *a: 'http://example.com')
    walls.first_photo = lambda: 'url'
    with errmsg('Error downloading image.\n'):
        walls.run(config_obj)
Exemplo n.º 2
0
def test_first_photo_invalid(monkeypatch, config_obj, errmsg):
    data = None
    monkeypatch.setattr('flickrapi.FlickrAPI.photos_getSizes',
                        lambda self, **kw: data, raising=False)
    monkeypatch.setattr('flickrapi.FlickrAPI.walk',
                        lambda self, **kw: [{'id': '1'}])
    for d in [[], {}, {'sizes': 1}, {'sizes': []}, {'sizes': {'size': 1}},
              {'sizes': {'size': [1]}}, {'sizes': {'size': [{}]}}]:
        data = d
        with errmsg('Unexpected data from Flickr.\n'):
            walls.run(config_obj)
Exemplo n.º 3
0
def test_run_empty_search(monkeypatch, config_obj, errmsg):
    monkeypatch.setattr('flickrapi.FlickrAPI.walk', lambda self, **kw: [])
    with errmsg('No matching photos found.\n'):
        walls.run(config_obj)