diff options
author | Ivan Alejandro <ivanalejandro0@yahoo.com.ar> | 2013-06-26 16:29:39 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@yahoo.com.ar> | 2013-06-26 16:29:39 -0300 |
commit | 0fe9f43baf0d9da887d595384f100146f27f2393 (patch) | |
tree | fc92bec526aafc0bec36e04b0d9f4d81e25c787c /src/leap/services/eip/eipconfig.py | |
parent | 3a0de3f36929f06edc9fa8a5c9e7b5471976a03c (diff) |
Improve VPNGatewaySelector tests coverage.
Add +13 and +14 timezones support.
Diffstat (limited to 'src/leap/services/eip/eipconfig.py')
-rw-r--r-- | src/leap/services/eip/eipconfig.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/leap/services/eip/eipconfig.py b/src/leap/services/eip/eipconfig.py index 97eb3dfb..9e3a9b29 100644 --- a/src/leap/services/eip/eipconfig.py +++ b/src/leap/services/eip/eipconfig.py @@ -37,6 +37,8 @@ class VPNGatewaySelector(object): """ VPN Gateway selector. """ + # http://www.timeanddate.com/time/map/ + equivalent_timezones = {13: -11, 14: -10} def __init__(self, eipconfig, tz_offset=None): ''' @@ -51,7 +53,12 @@ class VPNGatewaySelector(object): self._local_offset = tz_offset if tz_offset is None: - self._local_offset = self._get_local_offset() + tz_offset = self._get_local_offset() + + if tz_offset in self.equivalent_timezones: + tz_offset = self.equivalent_timezones[tz_offset] + + self._local_offset = tz_offset self._eipconfig = eipconfig @@ -71,6 +78,9 @@ class VPNGatewaySelector(object): if gateway_location is not None: gw_offset = int(locations[gateway['location']]['timezone']) + if gw_offset in self.equivalent_timezones: + gw_offset = self.equivalent_timezones[gw_offset] + gateway_distance = self._get_timezone_distance(gw_offset) ip = self._eipconfig.get_gateway_ip(idx) |