2022-12-05 01:01:45 +01:00
|
|
|
from .execfile import execfile
|
2018-01-27 19:52:27 +01:00
|
|
|
import os
|
2014-10-11 23:39:01 +02:00
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from pyhamtools.qsl import get_eqsl_users
|
|
|
|
|
|
2018-01-27 19:52:27 +01:00
|
|
|
test_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
fix_dir = os.path.join(test_dir, 'fixtures')
|
2014-10-11 23:39:01 +02:00
|
|
|
class Test_eqsl_methods:
|
|
|
|
|
|
|
|
|
|
def test_check_content_with_mocked_http_server(self, httpserver):
|
2018-01-27 19:52:27 +01:00
|
|
|
httpserver.serve_content(open(os.path.join(fix_dir, 'eqsl_data.html'), 'rb').read(), headers={'content-type': 'text/plain; charset=ISO-8859-1'})
|
2014-10-11 23:39:01 +02:00
|
|
|
|
2018-01-27 19:52:27 +01:00
|
|
|
namespace = {}
|
|
|
|
|
execfile(os.path.join(fix_dir,"eqsl_data.py"), namespace)
|
|
|
|
|
assert get_eqsl_users(url=httpserver.url) == namespace['eqsl_fixture']
|
2014-10-11 23:39:01 +02:00
|
|
|
|
|
|
|
|
def test_download_lotw_list_and_check_types(self):
|
|
|
|
|
|
|
|
|
|
data = get_eqsl_users()
|
|
|
|
|
assert isinstance(data, list)
|
|
|
|
|
for el in data:
|
2023-12-28 21:02:41 +01:00
|
|
|
assert isinstance(el, str)
|
2014-10-11 23:39:01 +02:00
|
|
|
assert len(data) > 1000
|
|
|
|
|
|
|
|
|
|
def test_with_invalid_url(self):
|
|
|
|
|
with pytest.raises(IOError):
|
|
|
|
|
get_eqsl_users(url="http://www.eqsl.cc/QSLCard/DownloadedFiles/AGMemberlist_my_unit_test.txt")
|