refined callsign algorithm

This commit is contained in:
dh1tw 2016-08-18 20:54:50 +08:00
parent f9bd608741
commit b4613f92e9
4 changed files with 53 additions and 7 deletions

View file

@ -102,6 +102,23 @@ response_prefix_VK9GMW_clublog = {
u'longitude': -155.8
}
response_callsign_exceptions_7N1PRD_0_clublog = {
u'adif': 339,
u'continent': u'AS',
u'country': u'JAPAN',
u'cqz': 25,
u'latitude': 35.7,
u'longitude': -139.8
}
response_callsign_exceptions_SV8GXQ_P_QRP_clublog = {
u'adif': 236,
u'continent': u'EU',
u'country': u'GREECE',
u'cqz': 20,
u'latitude': 38.0,
u'longitude': -23.7
}
response_Exception_VP8STI_with_start_and_stop_date = {
'adif': 240,
@ -221,6 +238,8 @@ class Test_callinfo_methods:
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
assert fix_callinfo._dismantle_callsign("7N1PRD/0") == response_callsign_exceptions_7N1PRD_0_clublog
assert fix_callinfo._dismantle_callsign("SV8GXQ/P/QRP") == response_callsign_exceptions_SV8GXQ_P_QRP_clublog
with pytest.raises(KeyError):
fix_callinfo._dismantle_callsign("OZ/JO85")

View file

@ -5,7 +5,7 @@ from datetime import datetime
import pytz
import redis
from pyhamtools import LookupLib
from pyhamtools import LookupLib, Callinfo
UTC = pytz.UTC
@ -13,6 +13,16 @@ UTC = pytz.UTC
r = redis.Redis()
response_Exception_VP8STI_with_start_and_stop_date = {
'adif': 240,
'country': u'SOUTH SANDWICH ISLANDS',
'continent': u'SA',
'latitude': -59.45,
'longitude': 27.4,
'cqz': 13,
}
class TestStoreDataInRedis:
def test_copy_data_in_redis(self, fixClublogXML, fix_redis):
@ -39,4 +49,9 @@ class TestStoreDataInRedis:
lib = LookupLib(lookuptype="redis", redis_prefix="CF", redis_instance=r)
fixCountryFile.copy_data_in_redis("CF", r)
assert lib.lookup_callsign("3D2RI") == fixCountryFile.lookup_callsign("3D2RI")
assert lib.lookup_prefix("DH") == fixCountryFile.lookup_prefix("DH")
assert lib.lookup_prefix("DH") == fixCountryFile.lookup_prefix("DH")
def test_redis_lookup(self, fixClublogXML, fix_redis):
timestamp = datetime(year=2016, month=1, day=20, tzinfo=UTC)
ci = Callinfo(fix_redis)
assert ci.get_all("VP8STI", timestamp) == response_Exception_VP8STI_with_start_and_stop_date