def test_read_url(mocker, tmpdir): isolib = mocker.patch('pyglottolog.iso.iso_639_3') isolib._open = lambda p: contextlib.closing(BytesIO(b'abcd')) assert iso.read_url(None) == 'abcd' assert len(tmpdir.listdir()) == 0 iso.read_url('p', cache_dir=str(tmpdir)) assert len(tmpdir.listdir()) == 1
def test_ChangeRequest(iso_data): iso.read_url(None) res = list(iso.ChangeRequest.iter(max_year=2007)) print(res) assert len(res) == 2 assert res[0].url == 'https://iso639-3.sil.org/request/2006-020' assert res[0].pdf == 'https://iso639-3.sil.org/sites/iso639-3/files/change_requests/2006/2006-020.pdf' assert res[0].year == '2006' _, (_, fields) = iso.change_request_as_source( res[0].Change_Request_Number, [res[0]], {'2006-020': '1234567'}) assert 'title' in fields assert 'glottolog_ref_id' in fields
def test_code_details(iso_data): iso.read_url(None) iso.read_url(None) details = iso.code_details('') assert 'Merged' in details['Retirement Remedy']
def test_bibtex(api_copy, iso_data, mocker): iso.read_url(None) assert iso.bibtex(api_copy, mocker.Mock(), max_year=2007) == 2