mirror of
https://github.com/dh1tw/pyhamtools.git
synced 2026-01-09 02:00:30 +01:00
Add tests
Signed-off-by: Dawid SQ6EMM <sq6emm@hamradio.pl>
This commit is contained in:
parent
a67daa1db3
commit
d944d9b045
|
|
@ -73,7 +73,7 @@ def locator_to_latlong (locator, center=True):
|
|||
"""converts Maidenhead locator in the corresponding WGS84 coordinates
|
||||
|
||||
Args:
|
||||
locator (string): Locator, either 4, 6 or 8 characters
|
||||
locator (string): Locator, either 4, 6, 8 or 10 characters
|
||||
center (bool): Center of (sub)square. By default True. If False, the south/western corner will be returned
|
||||
|
||||
Returns:
|
||||
|
|
@ -186,8 +186,8 @@ def calculate_distance(locator1, locator2):
|
|||
"""calculates the (shortpath) distance between two Maidenhead locators
|
||||
|
||||
Args:
|
||||
locator1 (string): Locator, either 4, 6 or 8 characters
|
||||
locator2 (string): Locator, either 4, 6 or 8 characters
|
||||
locator1 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
locator2 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
|
||||
Returns:
|
||||
float: Distance in km
|
||||
|
|
@ -231,8 +231,8 @@ def calculate_distance_longpath(locator1, locator2):
|
|||
"""calculates the (longpath) distance between two Maidenhead locators
|
||||
|
||||
Args:
|
||||
locator1 (string): Locator, either 4, 6 or 8 characters
|
||||
locator2 (string): Locator, either 4, 6 or 8 characters
|
||||
locator1 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
locator2 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
|
||||
Returns:
|
||||
float: Distance in km
|
||||
|
|
@ -262,8 +262,8 @@ def calculate_heading(locator1, locator2):
|
|||
"""calculates the heading from the first to the second locator
|
||||
|
||||
Args:
|
||||
locator1 (string): Locator, either 4, 6 or 8 characters
|
||||
locator2 (string): Locator, either 4, 6 or 6 characters
|
||||
locator1 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
locator2 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
|
||||
Returns:
|
||||
float: Heading in deg
|
||||
|
|
@ -305,8 +305,8 @@ def calculate_heading_longpath(locator1, locator2):
|
|||
"""calculates the heading from the first to the second locator (long path)
|
||||
|
||||
Args:
|
||||
locator1 (string): Locator, either 4, 6 or 8 characters
|
||||
locator2 (string): Locator, either 4, 6 or 8 characters
|
||||
locator1 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
locator2 (string): Locator, either 4, 6, 8 or 10 characters
|
||||
|
||||
Returns:
|
||||
float: Long path heading in deg
|
||||
|
|
@ -337,7 +337,7 @@ def calculate_sunrise_sunset(locator, calc_date=None):
|
|||
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
|
||||
|
||||
Args:
|
||||
locator1 (string): Maidenhead Locator, either 4, 6 or 8 characters
|
||||
locator1 (string): Maidenhead Locator, either 4, 6, 8 or 10 characters
|
||||
calc_date (datetime, optional): Starting datetime for the calculations (UTC)
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -3,4 +3,8 @@ pytest==4.6.11; python_version=='3.6'
|
|||
pytest-blockage>=0.2.2
|
||||
pytest-localserver>=0.5
|
||||
pytest-cov>=2.12
|
||||
maidenhead==1.6.0
|
||||
maidenhead==1.6.0
|
||||
requests
|
||||
bs4
|
||||
redis
|
||||
ephem
|
||||
|
|
|
|||
14
test.py
Normal file
14
test.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from pyhamtools.locator import latlong_to_locator
|
||||
from pyhamtools.locator import locator_to_latlong
|
||||
|
||||
print("51.12492, 16.94183")
|
||||
print(latlong_to_locator(51.124913194444446, 16.94184027777778,10))
|
||||
print(latlong_to_locator(51.12492, 16.94183,10))
|
||||
|
||||
print("JO81LC39AX")
|
||||
print(locator_to_latlong("JO81LC39AX"))
|
||||
|
||||
b="MN45GU30AN"
|
||||
print(b)
|
||||
print(locator_to_latlong(b))
|
||||
print(latlong_to_locator(45.83568,68.52518,10))
|
||||
|
|
@ -24,8 +24,8 @@ class Test_latlong_to_locator():
|
|||
assert latlong_to_locator(39.222916, -86.45416, 8) == "EM69SF53"
|
||||
|
||||
def test_latlong_to_locator_10chars_precision(self):
|
||||
assert latlong_to_locator(45.83568, 68.52518, precision=10) == "MN45GU30AN"
|
||||
assert latlong_to_locator(51.12492, 16.94183, 10) == "JO81LC39AX"
|
||||
assert latlong_to_locator(45.835677, 68.525173, precision=10) == "MN45GU30AN"
|
||||
assert latlong_to_locator(51.124913, 16.941840, 10) == "JO81LC39AX"
|
||||
|
||||
def test_latlong_to_locator_invalid_characters(self):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue