summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-08-30 19:54:37 +0200
committerRuben Pollan <meskio@sindominio.net>2017-08-31 12:56:43 +0200
commit663c87c221c42e081b5947e298bc9f0541e6913a (patch)
treed933acad5df919614e600aa1ae2e737ebcc6e472 /tests/unit
parentf19bfeb73fc19747bd02cbbd5c024de4dc86b5a8 (diff)
[feat] list vpn gateways in the order that they are going to be used
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/vpn/test_gateways.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/unit/vpn/test_gateways.py b/tests/unit/vpn/test_gateways.py
index d16e9103..eda2a222 100644
--- a/tests/unit/vpn/test_gateways.py
+++ b/tests/unit/vpn/test_gateways.py
@@ -128,6 +128,11 @@ class GatewaySelectorTestCase(unittest.TestCase):
assert gateways == [ips[4], ips[2], ips[3], ips[1]]
def test_apply_user_preferences(self):
+ def to_gateways(gws):
+ return [{'location': x[0], 'ip_address': x[1],
+ 'country_code': x[2]}
+ for x in gws]
+
preferred = {
'loc': ['anarres', 'paris__fr', 'montevideo'],
'cc': ['BR', 'AR', 'UY'],
@@ -138,8 +143,8 @@ class GatewaySelectorTestCase(unittest.TestCase):
('Rio de Janeiro', '1.1.1.1', 'BR'),
('Montevideo', '1.1.1.1', 'UY'),
('Cordoba', '1.1.1.1', 'AR')]
- ordered = selector.apply_user_preferences(pre)
- locations = [x[0] for x in ordered]
+ ordered = selector.apply_user_preferences(to_gateways(pre))
+ locations = [x['location'] for x in ordered]
# first the preferred location, then order by country
assert locations == [
'Montevideo',
@@ -152,8 +157,8 @@ class GatewaySelectorTestCase(unittest.TestCase):
('Montevideo', '', ''),
('Paris, FR', '', ''),
('AnaRreS', '', '')]
- ordered = selector.apply_user_preferences(pre)
- locations = [x[0] for x in ordered]
+ ordered = selector.apply_user_preferences(to_gateways(pre))
+ locations = [x['location'] for x in ordered]
# first the preferred location, then order by country
# (test normalization)
assert locations == [
@@ -167,8 +172,8 @@ class GatewaySelectorTestCase(unittest.TestCase):
('Tacuarembo', '', 'UY'),
('Sao Paulo', '', 'BR'),
('Cordoba', '', 'AR')]
- ordered = selector.apply_user_preferences(pre)
- locations = [x[0] for x in ordered]
+ ordered = selector.apply_user_preferences(to_gateways(pre))
+ locations = [x['location'] for x in ordered]
# no matching location, order by country
assert locations == [
'Rio De Janeiro',