mirror of
https://github.com/dh1tw/pyhamtools.git
synced 2026-04-05 14:35:49 +00:00
added qrz.com and callsign exception file
This commit is contained in:
parent
c037bcee71
commit
63eb9a2447
31 changed files with 1061 additions and 233 deletions
58
test/fixtures/lotw_data_with_errors.html
vendored
Normal file
58
test/fixtures/lotw_data_with_errors.html
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
1A0C,20-07-29
|
||||
1A0KM,20-02-08
|
||||
1A3A,20-09-12
|
||||
1A4A,20-09-16
|
||||
2A/DJ6AU,20-01-04
|
||||
2A0APF,20-11-23
|
||||
2A0APF/P,20-11-23
|
||||
2A0BQI,0000-10-03
|
||||
2A0BQI/P,20-10-03
|
||||
2A0BSM,20-12-31
|
||||
2A0MAV,20-11-23
|
||||
2C0TKX,20-05-15
|
||||
2C3SFC,2014-06-26
|
||||
2D0EBV/P,2006-10-26
|
||||
2D0YLX,2014-07-27
|
||||
2E0ADK,2014-02-18
|
||||
2E0ATS,2004-02-25
|
||||
2E0BBA,2010-08-19
|
||||
2E0BPP,2014-09-30
|
||||
2E0BXD,2011-12-29
|
||||
2E0BXO,2012-07-09
|
||||
2E0CAX,2006-07-11
|
||||
2E0CAX/P,2006-07-07
|
||||
2E0CHS,2008-12-05
|
||||
2E0CMD,2012-11-25
|
||||
2E0CMD/P,2012-11-25
|
||||
2E0CPJ,2013-03-22
|
||||
2E0CPT,2011-04-19
|
||||
2E0CQB,2014-06-14
|
||||
2E0CRY,2013-06-10
|
||||
2E0CXF,2014-05-24
|
||||
2E0DDG,2012-04-15
|
||||
2E0EBM,2014-07-21
|
||||
2E0EBV,2008-02-10
|
||||
2E0EBV/P,2006-07-03
|
||||
2E0EDL,2014-09-28
|
||||
2E0EET,2013-01-14
|
||||
2E0ETN,2012-06-06
|
||||
2E0ETT,2011-04-23
|
||||
2E0FAS,2014-08-31
|
||||
2E0FFQ,2008-12-10
|
||||
2E0FNG,2011-12-14
|
||||
2E0FSM,2014-09-19
|
||||
2E0GBC,2013-10-28
|
||||
2E0GBK,2014-07-31
|
||||
2E0GOL,2013-01-08
|
||||
2E0GSW,2013-12-28
|
||||
2E0GYC,2011-12-11
|
||||
2E0HEF,2014-08-26
|
||||
2E0HYE,2013-10-03
|
||||
2E0IAF,2014-09-28
|
||||
2E0IAF/P,2011-06-12
|
||||
2E0IFC,2014-09-28
|
||||
2E0IKW,2010-02-28
|
||||
2E0INV,2014-09-25
|
||||
2E0JAX,2013-05-01
|
||||
2E0JCA,2010-04-09
|
||||
2E0JCQ,2013-10-15
|
||||
|
|
@ -47,7 +47,65 @@ response_prefix_C6A_countryfile = {
|
|||
'ituz': 11
|
||||
}
|
||||
|
||||
response_prefix_VK9NDX_countryfile = {
|
||||
u'adif': 189,
|
||||
u'continent': u'OC',
|
||||
u'country': u'Norfolk Island',
|
||||
u'cqz': 32,
|
||||
u'ituz': 60,
|
||||
u'latitude': -29.03,
|
||||
u'longitude': -167.93
|
||||
}
|
||||
|
||||
response_prefix_VK9DNX_clublog = {
|
||||
u'adif': 189,
|
||||
u'continent': u'OC',
|
||||
u'country': u'NORFOLK ISLAND',
|
||||
u'cqz': 32,
|
||||
u'latitude': -29.0,
|
||||
u'longitude': -168.0
|
||||
}
|
||||
|
||||
response_prefix_VK9DWX_clublog = {
|
||||
u'adif': 303,
|
||||
u'continent': u'OC',
|
||||
u'country': u'WILLIS ISLAND',
|
||||
u'cqz': 30,
|
||||
u'latitude': -16.2,
|
||||
u'longitude': -150.0
|
||||
}
|
||||
|
||||
response_prefix_VK9DLX_clublog = {
|
||||
u'adif': 147,
|
||||
u'continent': u'OC',
|
||||
u'country': u'LORD HOWE ISLAND',
|
||||
u'cqz': 30,
|
||||
u'latitude': -31.6,
|
||||
u'longitude': -159.1
|
||||
}
|
||||
|
||||
response_prefix_VK9DLX_countryfile = {
|
||||
u'adif': 147,
|
||||
u'continent': u'OC',
|
||||
u'country': u'Lord Howe Island',
|
||||
u'cqz': 30,
|
||||
u'ituz': 60,
|
||||
u'latitude': -31.55,
|
||||
u'longitude': -159.08
|
||||
}
|
||||
|
||||
response_prefix_VK9GMW_clublog = {
|
||||
u'adif': 171,
|
||||
u'continent': u'OC',
|
||||
u'country': u'MELLISH REEF',
|
||||
u'cqz': 30,
|
||||
u'latitude': -17.6,
|
||||
u'longitude': -155.8
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
response_Exception_VK9XO_with_start_date = {
|
||||
'adif': 35,
|
||||
'country': 'CHRISTMAS ISLAND',
|
||||
|
|
@ -89,6 +147,18 @@ response_aircraft_mobile = {
|
|||
'longitude': 0.0
|
||||
}
|
||||
|
||||
response_callsign_exceptions_7QAA_clublog = {
|
||||
u'adif': 440,
|
||||
u'continent': u'AF',
|
||||
u'country': u'MALAWI',
|
||||
u'cqz': 37,
|
||||
u'latitude': -14.9,
|
||||
u'longitude': -34.4
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class Test_callinfo_methods:
|
||||
|
||||
def test_callinfo_iterate_prefix(self, fix_callinfo):
|
||||
|
|
@ -126,7 +196,7 @@ class Test_callinfo_methods:
|
|||
def test_dismantle_callsign(self, fix_callinfo):
|
||||
|
||||
if fix_callinfo._lookuplib._lookuptype == "clublogxml":
|
||||
#assert fix_callinfo._dismantle_callsign("DH1TW/BCN")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/BCN")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/QRP") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/QRPP") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/LH") == response_prefix_DH_clublog
|
||||
|
|
@ -134,28 +204,51 @@ class Test_callinfo_methods:
|
|||
assert fix_callinfo._dismantle_callsign("DH1TW/P") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/5") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/M") == response_prefix_DH_clublog
|
||||
#assert fix_callinfo._dismantle_callsign("DH1TW/B")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/B")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DL/HC2AO") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("9H5A/C6A") == response_prefix_C6A_clublog
|
||||
assert fix_callinfo._dismantle_callsign("C6A/9H5A") == response_prefix_C6A_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/UNI") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/BUX") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/NOT") == response_prefix_DH_clublog
|
||||
assert fix_callinfo._dismantle_callsign("VK9DLX/NOT") == response_prefix_VK9DLX_clublog
|
||||
assert fix_callinfo._dismantle_callsign("7QAA") == response_callsign_exceptions_7QAA_clublog
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
fix_callinfo._dismantle_callsign("OZ/JO85")
|
||||
|
||||
if fix_callinfo._lookuplib._lookuptype == "countryfile":
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/QRP") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/QRPP") == response_prefix_DH_countryfile
|
||||
#assert fix_callinfo._dismantle_callsign("DH1TW/BCN")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/BCN")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/LH") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("HC2AO/DL") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/P") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/5") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/M") == response_prefix_DH_countryfile
|
||||
#assert fix_callinfo._dismantle_callsign("DH1TW/B")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/B")[const.BEACON]
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DL/HC2AO") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("9H5A/C6A") == response_prefix_C6A_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("C6A/9H5A") == response_prefix_C6A_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("DH1TW/NOT") == response_prefix_DH_countryfile
|
||||
assert fix_callinfo._dismantle_callsign("VK9DLX/NOT") == response_prefix_VK9DLX_countryfile
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
fix_callinfo._dismantle_callsign("OZ/JO85")
|
||||
|
||||
|
||||
def test_dismantle_callsign_with_VK9_special_suffixes(self, fix_callinfo):
|
||||
|
||||
if fix_callinfo._lookuplib._lookuptype == "clublog":
|
||||
assert fix_callinfo._dismantle_callsign("VK9DNX") == response_prefix_VK9DNX_clublog
|
||||
assert fix_callinfo._dismantle_callsign("VK9DLX") == response_prefix_VK9DLX_clublog
|
||||
assert fix_callinfo._dismantle_callsign("VK9GMX") == response_prefix_VK9GMW_clublog
|
||||
assert fix_callinfo._dismantle_callsign("VK9DWX") == response_prefix_VK9DWX_clublog
|
||||
|
||||
|
||||
def test_lookup_callsign(selfself, fix_callinfo):
|
||||
def test_lookup_callsign(self, fix_callinfo):
|
||||
|
||||
assert fix_callinfo._lookup_callsign("DH1TW/MM") == response_maritime_mobile
|
||||
assert fix_callinfo._lookup_callsign("DH1TW/AM") == response_aircraft_mobile
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ 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'})
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ from pyhamtools.exceptions import APIKeyMissingError
|
|||
|
||||
response_Exception_DH1TW = {
|
||||
'adif': 230,
|
||||
'country': 'FEDERAL REPUBLIC OF GERMANY',
|
||||
'continent': 'EU',
|
||||
'country': u'FEDERAL REPUBLIC OF GERMANY',
|
||||
'continent': u'EU',
|
||||
'latitude': 51.0,
|
||||
'longitude': -10.0,
|
||||
'cqz': 14
|
||||
|
|
@ -19,8 +19,8 @@ response_Exception_DH1TW = {
|
|||
|
||||
response_Exception_VU9KV = {
|
||||
'adif': 324,
|
||||
'country': 'INDIA',
|
||||
'continent': 'AS',
|
||||
'country': u'INDIA',
|
||||
'continent': u'AS',
|
||||
'latitude': 22.0,
|
||||
'longitude': -80.0,
|
||||
'cqz': 22
|
||||
|
|
@ -29,8 +29,8 @@ response_Exception_VU9KV = {
|
|||
|
||||
response_Exception_VU9KV_with_Date = {
|
||||
'adif': 11,
|
||||
'country': 'ANDAMAN & NICOBAR ISLANDS',
|
||||
'continent': 'AS',
|
||||
'country': u'ANDAMAN & NICOBAR ISLANDS',
|
||||
'continent': u'AS',
|
||||
'latitude': 11.70,
|
||||
'longitude': -92.80,
|
||||
'cqz': 26
|
||||
|
|
@ -39,8 +39,8 @@ response_Exception_VU9KV_with_Date = {
|
|||
|
||||
response_Exception_DH1TW_MM = {
|
||||
'adif': 999,
|
||||
'country': 'MARITIME MOBILE',
|
||||
'continent': '',
|
||||
'country': u'MARITIME MOBILE',
|
||||
'continent': u'',
|
||||
'latitude': 0.0,
|
||||
'longitude': 0.0,
|
||||
'cqz': 0
|
||||
|
|
@ -48,8 +48,8 @@ response_Exception_DH1TW_MM = {
|
|||
|
||||
response_Exception_DH1TW_AM = {
|
||||
'adif': 998,
|
||||
'country': 'AIRCRAFT MOBILE',
|
||||
'continent': '',
|
||||
'country': u'AIRCRAFT MOBILE',
|
||||
'continent': u'',
|
||||
'longitude': 0.0,
|
||||
'latitude': 0.0,
|
||||
'cqz': 0
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ UTC = pytz.UTC
|
|||
|
||||
|
||||
response_Entity_230 = {
|
||||
'country': 'FEDERAL REPUBLIC OF GERMANY',
|
||||
'continent': 'EU',
|
||||
'country': u'FEDERAL REPUBLIC OF GERMANY',
|
||||
'continent': u'EU',
|
||||
'latitude': 51.0,
|
||||
'longitude': -10.0,
|
||||
'cqz': 14,
|
||||
'prefix' : 'DL',
|
||||
'prefix' : u'DL',
|
||||
'deleted' : False,
|
||||
}
|
||||
|
||||
response_Exception_KC6MM_1990 = {
|
||||
'adif': 22,
|
||||
'country': 'PALAU',
|
||||
'continent': 'OC',
|
||||
'country': u'PALAU',
|
||||
'continent': u'OC',
|
||||
'latitude': 9.50,
|
||||
'longitude': -138.20,
|
||||
'cqz': 27,
|
||||
|
|
@ -35,8 +35,8 @@ response_Exception_KC6MM_1990 = {
|
|||
|
||||
response_Exception_KC6MM_1992 = {
|
||||
'adif': 22,
|
||||
'country': 'PALAU',
|
||||
'continent': 'OC',
|
||||
'country': u'PALAU',
|
||||
'continent': u'OC',
|
||||
'latitude': 9.50,
|
||||
'longitude': -138.20,
|
||||
'cqz': 27,
|
||||
|
|
@ -45,8 +45,8 @@ response_Exception_KC6MM_1992 = {
|
|||
|
||||
response_Exception_VK9XX_with_end_date = {
|
||||
'adif': 35,
|
||||
'country': 'CHRISTMAS ISLAND',
|
||||
'continent': 'OC',
|
||||
'country': u'CHRISTMAS ISLAND',
|
||||
'continent': u'OC',
|
||||
'latitude': -10.50,
|
||||
'longitude': -105.70,
|
||||
'cqz': 29,
|
||||
|
|
@ -54,8 +54,8 @@ response_Exception_VK9XX_with_end_date = {
|
|||
|
||||
response_Exception_VK9XO_with_start_date = {
|
||||
'adif': 35,
|
||||
'country': 'CHRISTMAS ISLAND',
|
||||
'continent': 'OC',
|
||||
'country': u'CHRISTMAS ISLAND',
|
||||
'continent': u'OC',
|
||||
'latitude': -10.50,
|
||||
'longitude': -105.70,
|
||||
'cqz': 29,
|
||||
|
|
@ -63,44 +63,44 @@ response_Exception_VK9XO_with_start_date = {
|
|||
|
||||
response_Exception_AX9NYG = {
|
||||
'adif': 38,
|
||||
'country': 'COCOS (KEELING) ISLAND',
|
||||
'continent': 'OC',
|
||||
'country': u'COCOS (KEELING) ISLAND',
|
||||
'continent': u'OC',
|
||||
'latitude': -12.20,
|
||||
'longitude': -96.80,
|
||||
'cqz': 29,
|
||||
}
|
||||
|
||||
response_Prefix_DH = {
|
||||
'country': 'FEDERAL REPUBLIC OF GERMANY',
|
||||
'country': u'FEDERAL REPUBLIC OF GERMANY',
|
||||
'adif' : 230,
|
||||
'continent': 'EU',
|
||||
'continent': u'EU',
|
||||
'latitude': 51.0,
|
||||
'longitude': -10.0,
|
||||
'cqz': 14,
|
||||
}
|
||||
|
||||
response_Prefix_VK9_until_1975 = {
|
||||
'country': 'PAPUA TERR',
|
||||
'country': u'PAPUA TERR',
|
||||
'adif' : 198,
|
||||
'continent': 'OC',
|
||||
'continent': u'OC',
|
||||
'latitude': -9.40,
|
||||
'longitude': -147.10,
|
||||
'cqz': 28,
|
||||
}
|
||||
|
||||
response_Prefix_VK9_starting_1976 = {
|
||||
'country': 'NORFOLK ISLAND',
|
||||
'country': u'NORFOLK ISLAND',
|
||||
'adif' : 189,
|
||||
'continent': 'OC',
|
||||
'continent': u'OC',
|
||||
'latitude': -29.00,
|
||||
'longitude': -168.00,
|
||||
'cqz': 32,
|
||||
}
|
||||
|
||||
response_Prefix_ZD5_1964_to_1971 = {
|
||||
'country': 'SWAZILAND',
|
||||
'country': u'SWAZILAND',
|
||||
'adif' : 468,
|
||||
'continent': 'AF',
|
||||
'continent': u'AF',
|
||||
'latitude': -26.30,
|
||||
'longitude': -31.10,
|
||||
'cqz': 38,
|
||||
|
|
|
|||
|
|
@ -53,13 +53,13 @@ class Test_Getter_Setter_Api_Types_for_all_sources:
|
|||
count = 0
|
||||
for attr in entity:
|
||||
if attr == "country":
|
||||
assert type(entity[attr] is str)
|
||||
assert type(entity[attr] is unicode)
|
||||
count +=1
|
||||
if attr == "continent":
|
||||
assert type(entity[attr] is str)
|
||||
assert type(entity[attr] is unicode)
|
||||
count +=1
|
||||
if attr == "prefix":
|
||||
assert type(entity[attr] is str)
|
||||
assert type(entity[attr] is unicode)
|
||||
count +=1
|
||||
if attr == "deleted":
|
||||
assert type(entity[attr] is bool)
|
||||
|
|
@ -109,10 +109,10 @@ class Test_Getter_Setter_Api_Types_for_all_sources:
|
|||
assert type(ex[attr]) is float
|
||||
count +=1
|
||||
elif attr == "country":
|
||||
assert type(ex[attr]) is str
|
||||
assert type(ex[attr]) is unicode
|
||||
count +=1
|
||||
elif attr == "continent":
|
||||
assert type(ex[attr]) is str
|
||||
assert type(ex[attr]) is unicode
|
||||
count +=1
|
||||
elif attr == "cqz":
|
||||
assert type(ex[attr]) is int
|
||||
|
|
@ -145,7 +145,7 @@ class Test_Getter_Setter_Api_Types_for_all_sources:
|
|||
count = 0
|
||||
for attr in prefix:
|
||||
if attr == "country":
|
||||
assert type(prefix[attr]) is str
|
||||
assert type(prefix[attr]) is unicode
|
||||
count +=1
|
||||
elif attr == "adif":
|
||||
assert type(prefix[attr]) is int
|
||||
|
|
@ -157,7 +157,7 @@ class Test_Getter_Setter_Api_Types_for_all_sources:
|
|||
assert type(prefix[attr]) is int
|
||||
count +=1
|
||||
elif attr == "continent":
|
||||
assert type(prefix[attr]) is str
|
||||
assert type(prefix[attr]) is unicode
|
||||
count +=1
|
||||
elif attr == "latitude":
|
||||
assert type(prefix[attr]) is float
|
||||
|
|
|
|||
242
test/test_lookuplib_qrz.py
Normal file
242
test/test_lookuplib_qrz.py
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
import pytest
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
from apikey import QRZ_USERNAME, QRZ_PWD
|
||||
from pyhamtools.lookuplib import LookupLib
|
||||
from pyhamtools.exceptions import APIKeyMissingError
|
||||
from pyhamtools.consts import LookupConventions as const
|
||||
|
||||
import pytz
|
||||
UTC = pytz.UTC
|
||||
|
||||
#Fixtures
|
||||
#===========================================================
|
||||
|
||||
response_XX1XX = {
|
||||
# 'u_views': u'17495',
|
||||
u'biodate': datetime(2015, 2, 4, 17, 50, 32, tzinfo=UTC),
|
||||
u'image': u'http://files.qrz.com/x/xx1xx/DSC_0094.png',
|
||||
u'locator': u'KF05nx',
|
||||
u'addr2': u'TEST CALLSIGN CITY',
|
||||
u'addr1': u'DO NOT QSL',
|
||||
u'aliases': [u'YY1YY'],
|
||||
u'codes': u'TPS',
|
||||
u'zipcode': u'010101',
|
||||
u'lotw': True,
|
||||
u'state': u'JC',
|
||||
u'callsign': u'XX1XX',
|
||||
u'fname': u'James W.',
|
||||
u'latitude': -34.010735,
|
||||
u'longitude': 21.164476,
|
||||
u'email': u'trucker2345@easymail.com',
|
||||
u'qslmgr': u'NO QSL - TEST CALLSIGN',
|
||||
u'bio': u'10415',
|
||||
u'ccode': 120,
|
||||
u'geoloc': u'user',
|
||||
u'eqsl': True,
|
||||
u'mqsl': True,
|
||||
u'adif': 134,
|
||||
u'moddate': datetime(2015, 2, 4, 17, 53, 2, tzinfo=UTC),
|
||||
u'license_class': u'z',
|
||||
u'land': u'Kingman Reef',
|
||||
u'imageinfo': u'425:640:425545',
|
||||
u'name': 'Smith',
|
||||
u'born': 2002,
|
||||
u'country': u'Iceland',
|
||||
u'user': u'XX1XX'
|
||||
}
|
||||
|
||||
|
||||
response_XX2XX = {
|
||||
u'bio': u'93',
|
||||
u'land': u'NON-DXCC',
|
||||
u'adif': 0,
|
||||
u'zipcode': u'23232',
|
||||
u'country': u'Anguilla',
|
||||
u'user': u'XX2XX',
|
||||
u'moddate': datetime(2015, 3, 20, 23, 20, 37, tzinfo=UTC),
|
||||
u'lotw': False,
|
||||
u'ccode': 9,
|
||||
u'geoloc': u'dxcc',
|
||||
u'state': u'GA',
|
||||
u'eqsl': False,
|
||||
u'addr2': u'Las Vegas',
|
||||
# 'u_views': u'23',
|
||||
u'fname': u'NO',
|
||||
u'addr1': u'123 Main Stod\u00DFer',
|
||||
u'callsign': u'XX2XX',
|
||||
u'mqsl': False,
|
||||
u'biodate': datetime(2015, 2, 19, 22, 30, 2, tzinfo=UTC),
|
||||
u'image': u'http://files.qrz.com/x/xx2xx/oval_bumper_sticker4.png',
|
||||
u'imageinfo': u'285:500:44218'
|
||||
}
|
||||
|
||||
response_XX3XX = {
|
||||
# 'u_views': u'4698',
|
||||
u'biodate': datetime(2014, 8, 13, 15, 34, 57, tzinfo=UTC),
|
||||
u'image': u'http://files.qrz.com/x/xx3xx/IMG_8813.JPG',
|
||||
u'locator': u'FO51sj',
|
||||
u'addr2': u'Shady Circle Roads',
|
||||
u'addr1': u'1234 Main St.3',
|
||||
u'aliases': [u'XX3XX/W7'],
|
||||
u'zipcode': u'00033',
|
||||
u'lotw': False,
|
||||
u'state': u'JJ',
|
||||
u'callsign': u'XX3XX',
|
||||
u'fname': u'TEST\xc3\x9c\xc3\x9f\xc3\xb8x',
|
||||
u'latitude': 51.396953,
|
||||
u'email': u'fred@qrz.com',
|
||||
u'qslmgr': u'Via BURO or AA7BQ',
|
||||
u'bio': u'2420',
|
||||
u'ccode': 130,
|
||||
u'geoloc': u'user',
|
||||
u'eqsl': False,
|
||||
u'user': u'KF7WIS',
|
||||
u'adif': 79,
|
||||
u'moddate': datetime(2014, 6, 6, 23, 0, 45, tzinfo=UTC),
|
||||
u'license_class': u'3',
|
||||
u'land': u'Guadeloupe',
|
||||
u'imageinfo': u'540:799:101014',
|
||||
u'name': u'CALLSIGN3',
|
||||
u'born': 2010,
|
||||
u'country': u'Jamaica',
|
||||
u'longitude': -68.41959,
|
||||
u'mqsl': False
|
||||
}
|
||||
|
||||
response_XX4XX = {
|
||||
# 'u_views': u'7980',
|
||||
u'biodate': datetime(2014, 9, 17, 19, 46, 54, tzinfo=UTC),
|
||||
u'image': u'http://files.qrz.com/x/xx4xx/IMG_0032.JPG',
|
||||
u'locator': u'DM79mp',
|
||||
u'addr2': u'Getamap and Findit',
|
||||
u'addr1': u'Test Callsign for QRZ',
|
||||
u'imageinfo': u'1200:1600:397936',
|
||||
u'lotw': False,
|
||||
u'state': u'ZZ',
|
||||
u'callsign': u'XX4XX',
|
||||
u'fname': u'Arthur',
|
||||
u'latitude': 39.645,
|
||||
u'iota': u'NA-075',
|
||||
u'qslmgr': u'NO QSL - TEST CALLSIGN',
|
||||
u'bio': u'785',
|
||||
u'ccode': 34,
|
||||
u'geoloc': u'user',
|
||||
u'eqsl': False,
|
||||
u'user': u'XX2XX',
|
||||
u'adif': 64,
|
||||
u'moddate': datetime(2014, 3, 28, 20, 29, 42, tzinfo=UTC),
|
||||
u'name': u'Fay',
|
||||
u'land': u'Bermuda',
|
||||
u'zipcode': u'12345',
|
||||
u'country': u'Bermuda',
|
||||
u'longitude': -104.96,
|
||||
u'mqsl': False
|
||||
}
|
||||
|
||||
response_333 = {
|
||||
const.COUNTRY: u'Iraq',
|
||||
u'cc': u'IQ',
|
||||
const.LONGITUDE: 44.362793,
|
||||
const.CQZ: 21,
|
||||
const.ITUZ: 39,
|
||||
const.LATITUDE: 33.358062,
|
||||
u'timezone': 3.0,
|
||||
const.ADIF: 333,
|
||||
const.CONTINENT: u'AS',
|
||||
u'ccc': u'IRQ'
|
||||
}
|
||||
|
||||
#TESTS
|
||||
#===========================================================
|
||||
|
||||
|
||||
class TestQrzConstructur:
|
||||
|
||||
def test_get_session_key(self):
|
||||
lib = LookupLib(lookuptype="qrz", username=QRZ_USERNAME, pwd=QRZ_PWD)
|
||||
assert len(lib._apikey) == 32
|
||||
|
||||
def test_get_session_key_with_invalid_username(self):
|
||||
with pytest.raises(ValueError):
|
||||
lib = LookupLib(lookuptype="qrz", username="hello", pwd=QRZ_PWD)
|
||||
|
||||
def test_get_session_key_with_invalid_password(self):
|
||||
with pytest.raises(ValueError):
|
||||
lib = LookupLib(lookuptype="qrz", username=QRZ_USERNAME, pwd="hello")
|
||||
|
||||
def test_get_session_key_with_empty_username_and_password(self):
|
||||
with pytest.raises(ValueError):
|
||||
lib = LookupLib(lookuptype="qrz", username="", pwd="")
|
||||
|
||||
|
||||
class TestQrz_Callsign_Lookup:
|
||||
|
||||
def test_lookup_callsign(self, fix_qrz):
|
||||
data = fix_qrz._lookup_qrz_callsign("xx1xx", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX1XX #check content
|
||||
assert len(data) == len(response_XX1XX) #ensure all fields are included
|
||||
|
||||
data = fix_qrz._lookup_qrz_callsign("XX1XX", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX1XX
|
||||
|
||||
data = fix_qrz._lookup_qrz_callsign("XX2XX", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX2XX
|
||||
assert len(data) == len(response_XX2XX)
|
||||
|
||||
data = fix_qrz._lookup_qrz_callsign("XX3XX", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX3XX
|
||||
assert len(data) == len(response_XX3XX)
|
||||
|
||||
data = fix_qrz._lookup_qrz_callsign("XX4XX", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX4XX
|
||||
assert len(data) == len(response_XX4XX)
|
||||
|
||||
def test_lookup_callsign_with_unicode_escaping(self, fix_qrz):
|
||||
data = fix_qrz._lookup_qrz_callsign("XX2XX", fix_qrz._apikey)
|
||||
data.pop('u_views', None)
|
||||
assert data == response_XX2XX
|
||||
|
||||
def test_lookup_callsign_does_not_exist(self, fix_qrz):
|
||||
with pytest.raises(KeyError):
|
||||
fix_qrz._lookup_qrz_callsign("XX8XX", fix_qrz._apikey)
|
||||
|
||||
def test_lookup_callsign_with_empty_input(self, fix_qrz):
|
||||
with pytest.raises(ValueError):
|
||||
fix_qrz._lookup_qrz_callsign("", fix_qrz._apikey)
|
||||
|
||||
def test_lookup_callsign_with_invalid_input(self, fix_qrz):
|
||||
with pytest.raises(AttributeError):
|
||||
fix_qrz._lookup_qrz_callsign(3, fix_qrz._apikey)
|
||||
|
||||
|
||||
class TestQrz_DXCC_Lookup:
|
||||
|
||||
def test_lookup_dxcc_with_int(self, fix_qrz):
|
||||
data = fix_qrz._lookup_qrz_dxcc(333, fix_qrz._apikey)
|
||||
assert data == response_333 #check content
|
||||
assert len(data) == len(response_333) #ensure all fields are included
|
||||
|
||||
def test_lookup_dxcc_with_string(self, fix_qrz):
|
||||
data = fix_qrz._lookup_qrz_dxcc("333", fix_qrz._apikey)
|
||||
assert data == response_333 #check content
|
||||
assert len(data) == len(response_333) #ensure all fields are included
|
||||
|
||||
def test_lookup_dxcc_does_not_exist(self, fix_qrz):
|
||||
with pytest.raises(KeyError):
|
||||
fix_qrz._lookup_qrz_dxcc('854', fix_qrz._apikey)
|
||||
|
||||
def test_lookup_dxcc_wrong_input(self, fix_qrz):
|
||||
with pytest.raises(ValueError):
|
||||
fix_qrz._lookup_qrz_dxcc('', fix_qrz._apikey)
|
||||
|
||||
def test_lookup_dxcc(self, fix_qrz):
|
||||
data = fix_qrz.lookup_entity(333)
|
||||
assert data == response_333 #check content
|
||||
|
||||
|
|
@ -26,4 +26,11 @@ class Test_lotw_methods:
|
|||
with pytest.raises(IOError):
|
||||
get_lotw_users(url="http://wd5eae.org/LoTW_Data_XXXXX.txt")
|
||||
|
||||
def test_with_more_than_10_invalid_dates(self, httpserver):
|
||||
httpserver.serve_content(open('./fixtures/lotw_data_with_errors.html').read())
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
get_lotw_users(url=httpserver.url)
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue