Example #1
0
    def test_host_attrs_alias(self):
        host = Host(name='test',
                    ansible_ssh_pass='******')

        self.assertEqual(host.name, 'test')
        self.assertEqual(host.ansible_password, 'testpass')
        self.assertEqual(host.ansible_ssh_pass, 'testpass')
Example #2
0
    def test_host_vars_kwargs(self):
        host = Host(name='test',
                    ansible_host='testhost',
                    key1='value1',
                    key2='value2')

        self.assertEqual(host.name, 'test')
        self.assertEqual(host.ansible_host, 'testhost')
        self.assertEqual(host.vars, {'key1': 'value1', 'key2': 'value2'})
Example #3
0
    def test_host_attrs(self):
        host = Host(name='test',
                    ansible_host='testhost',
                    ansible_user='******',
                    ansible_password='******',
                    ansible_network_os='openvswitch')

        self.assertEqual(host.name, 'test')
        self.assertEqual(host.ansible_host, 'testhost')
        self.assertEqual(host.ansible_user, 'testuser')
        self.assertEqual(host.ansible_password, 'testpass')
        self.assertEqual(host.ansible_ssh_pass, 'testpass')
        self.assertEqual(host.ansible_network_os, 'openvswitch')
Example #4
0
    def test_empty_host(self):
        host = Host(name='test')
        self.assertEqual(type(host), Host)

        serialized_host = host.serialize()
        self.assertEqual(serialized_host, TEST_HOST)

        host.deserialize(TEST_HOST)
        self.assertEqual(host, Host(name='test'))
Example #5
0
 def test_host_vars(self):
     host = Host(name='test')
     host.vars['testvar'] = 'testing123'
     self.assertEqual(host.vars['testvar'], 'testing123')
Example #6
0
 def test_add_host(self):
     host = Host(name='test')
     api = NetworkRunner()
     assert 'test' not in api.inventory.hosts
     api.add_host(host)
     assert 'test' in api.inventory.hosts
Example #7
0
 def test_get_host_by_ansible_host(self):
     host = Host(name='test1', ansible_host='test2')
     api = NetworkRunner()
     api.add_host(host)
     ret = api.has_host('test2')
     self.assertTrue(ret)
Example #8
0
 def test_get_host_fail(self):
     host = Host(name='test1')
     api = NetworkRunner()
     api.add_host(host)
     ret = api.has_host('test')
     self.assertFalse(ret)