From b655d5798b4d9394df9bafcce352cad881bdb3a0 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 19 Aug 2013 20:13:32 +0200 Subject: [PATCH] add tests for the -i option when used with raw string for ipv4 and ipv6 addresses. --- test/TestInventory.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/TestInventory.py b/test/TestInventory.py index 34cb1de43be..e1d043dacd0 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -114,6 +114,36 @@ class TestInventory(unittest.TestCase): print expected_hosts assert sorted(hosts) == sorted(expected_hosts) + def test_simple_string_ipv4(self): + inventory = Inventory('127.0.0.1,192.168.1.1') + hosts = inventory.list_hosts() + self.assertEqual(sorted(hosts), sorted(['127.0.0.1','192.168.1.1'])) + + def test_simple_string_ipv4_port(self): + inventory = Inventory('127.0.0.1:2222,192.168.1.1') + hosts = inventory.list_hosts() + self.assertEqual(sorted(hosts), sorted(['127.0.0.1','192.168.1.1'])) + + def test_simple_string_ipv4_vars(self): + inventory = Inventory('127.0.0.1:2222,192.168.1.1') + var = inventory.get_variables('127.0.0.1') + self.assertEqual(var['ansible_ssh_port'], 2222) + + def test_simple_string_ipv6(self): + inventory = Inventory('FE80:EF45::12:1,192.168.1.1') + hosts = inventory.list_hosts() + self.assertEqual(sorted(hosts), sorted(['FE80:EF45::12:1','192.168.1.1'])) + + def test_simple_string_ipv6_port(self): + inventory = Inventory('[FE80:EF45::12:1]:2222,192.168.1.1') + hosts = inventory.list_hosts() + self.assertEqual(sorted(hosts), sorted(['FE80:EF45::12:1','192.168.1.1'])) + + def test_simple_string_ipv6_vars(self): + inventory = Inventory('[FE80:EF45::12:1]:2222,192.168.1.1') + var = inventory.get_variables('FE80:EF45::12:1') + self.assertEqual(var['ansible_ssh_port'], 2222) + def test_simple_vars(self): inventory = self.simple_inventory() vars = inventory.get_variables('thor')