2015-12-19 04:19:48 +01:00
|
|
|
# Project imports
|
|
|
|
import os
|
2015-12-19 09:04:44 +01:00
|
|
|
import random
|
2015-12-19 04:19:48 +01:00
|
|
|
import re
|
2015-12-19 09:04:44 +01:00
|
|
|
import sys
|
2015-12-19 04:19:48 +01:00
|
|
|
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
|
|
|
|
|
|
|
|
import helper
|
|
|
|
from elodie import geolocation
|
|
|
|
|
|
|
|
os.environ['TZ'] = 'GMT'
|
|
|
|
|
|
|
|
def test_decimal_to_dms():
|
|
|
|
|
2015-12-19 09:04:44 +01:00
|
|
|
for x in range(0, 1000):
|
|
|
|
target_decimal_value = random.uniform(0.0, 180.0)
|
|
|
|
if(x % 2 == 1):
|
|
|
|
target_decimal_value = target_decimal_value * -1
|
|
|
|
|
|
|
|
dms = geolocation.decimal_to_dms(target_decimal_value)
|
|
|
|
check_value = dms[0].to_float() + dms[1].to_float() / 60 + dms[2].to_float() / 3600
|
|
|
|
|
|
|
|
target_decimal_value = round(target_decimal_value, 8)
|
|
|
|
check_value = round(check_value, 8)
|
2015-12-19 04:19:48 +01:00
|
|
|
|
2015-12-19 09:04:44 +01:00
|
|
|
assert target_decimal_value == check_value, '%s does not match %s' % (check_value, target_decimal_value)
|