mirror of
https://github.com/dh1tw/pyhamtools.git
synced 2026-04-05 22:45:42 +00:00
Added pyhamtools.qsl to load LOTW and EQSL user list
This commit is contained in:
parent
beb8862ebe
commit
250d8e6b79
16 changed files with 162799 additions and 12 deletions
|
|
@ -3,10 +3,11 @@ import tempfile
|
|||
import os
|
||||
|
||||
|
||||
from apikey import APIKEY
|
||||
from apikey import APIKEY, QRZ_USERNAME, QRZ_PWD
|
||||
from pyhamtools import LookupLib
|
||||
from pyhamtools import Callinfo
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", params=["a", "", 12.5, -5, {"foo" : "bar"}, [5, "foo"]])
|
||||
def fixNonUnsignedInteger(request):
|
||||
return request.param
|
||||
|
|
@ -39,9 +40,6 @@ def fixLists(request):
|
|||
def fixNone(request):
|
||||
return request.param
|
||||
|
||||
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def fixApiKey(request):
|
||||
return(APIKEY)
|
||||
|
|
@ -77,4 +75,8 @@ def fix_callinfo(request, fixApiKey):
|
|||
@pytest.fixture(scope="module")
|
||||
def fix_redis():
|
||||
import redis
|
||||
return LookupLib(lookuptype="redis", redis_instance=redis.Redis(), redis_prefix="clx")
|
||||
return LookupLib(lookuptype="redis", redis_instance=redis.Redis(), redis_prefix="clx")
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def fix_qrz():
|
||||
return LookupLib(lookuptype="qrz", username=QRZ_USERNAME, pwd=QRZ_PWD)
|
||||
|
|
|
|||
85662
test/fixtures/eqsl_data.html
vendored
Normal file
85662
test/fixtures/eqsl_data.html
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
test/fixtures/eqsl_data.py
vendored
Normal file
1
test/fixtures/eqsl_data.py
vendored
Normal file
File diff suppressed because one or more lines are too long
76928
test/fixtures/lotw_data.html
vendored
Normal file
76928
test/fixtures/lotw_data.html
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
test/fixtures/lotw_data.py
vendored
Normal file
1
test/fixtures/lotw_data.py
vendored
Normal file
File diff suppressed because one or more lines are too long
27
test/test_eqsl.py
Normal file
27
test/test_eqsl.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import os
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from pyhamtools.qsl import get_eqsl_users
|
||||
|
||||
class Test_eqsl_methods:
|
||||
|
||||
|
||||
def test_check_content_with_mocked_http_server(self, httpserver):
|
||||
httpserver.serve_content(open('./fixtures/eqsl_data.html').read(), headers={'content-type': 'text/plain; charset=ISO-8859-1'})
|
||||
|
||||
exec(open(os.path.join("./fixtures/","eqsl_data.py")).read())
|
||||
assert get_eqsl_users(url=httpserver.url) == eqsl_fixture
|
||||
|
||||
def test_download_lotw_list_and_check_types(self):
|
||||
|
||||
data = get_eqsl_users()
|
||||
assert isinstance(data, list)
|
||||
for el in data:
|
||||
assert isinstance(el, unicode)
|
||||
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")
|
||||
29
test/test_lotw.py
Normal file
29
test/test_lotw.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from pyhamtools.qsl import get_lotw_users
|
||||
|
||||
class Test_lotw_methods:
|
||||
|
||||
def test_check_content_with_mocked_http_server(self, httpserver):
|
||||
httpserver.serve_content(open('./fixtures/lotw_data.html').read())
|
||||
|
||||
exec(open(os.path.join("./fixtures/","lotw_data.py")).read())
|
||||
assert get_lotw_users(url=httpserver.url) == lotw_fixture
|
||||
|
||||
def test_download_lotw_list_and_check_types(self):
|
||||
|
||||
data = get_lotw_users()
|
||||
assert isinstance(data, dict)
|
||||
for key, value in data.iteritems():
|
||||
assert isinstance(key, unicode)
|
||||
assert isinstance(value, datetime.datetime )
|
||||
assert len(data) > 1000
|
||||
|
||||
def test_with_invalid_url(self):
|
||||
with pytest.raises(IOError):
|
||||
get_lotw_users(url="http://wd5eae.org/LoTW_Data_XXXXX.txt")
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue