Exemple #1
0
    def test_has_pair(self):
        '''
        Tests return True / False if the alias is set
        '''
        self.assertTrue(hosts.has_pair('10.10.10.10', 'Salt1'))

        self.assertFalse(hosts.has_pair('10.10.10.10', 'Salt3'))
Exemple #2
0
    def test_has_pair(self):
        '''
        Tests return True / False if the alias is set
        '''
        self.assertTrue(hosts.has_pair('10.10.10.10', 'Salt1'))

        self.assertFalse(hosts.has_pair('10.10.10.10', 'Salt3'))
Exemple #3
0
    def test_has_pair(self):
        """
        Tests return True / False if the alias is set
        """
        self.assertTrue(hosts.has_pair("10.10.10.10", "Salt1"))

        self.assertFalse(hosts.has_pair("10.10.10.10", "Salt3"))
Exemple #4
0
 def test_rm_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     rm_host.hosts_filename = tmp
     assert has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'myname')
     assert not has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'unknown')
Exemple #5
0
 def test_rm_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     rm_host.hosts_filename = tmp
     assert has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'myname')
     assert not has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'unknown')
Exemple #6
0
    def test_has_pair(self):
        '''
        Tests return True / False if the alias is set
        '''
        with patch('salt.modules.hosts._list_hosts',
                   MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
            self.assertTrue(hosts.has_pair('10.10.10.10', 'Salt1'))

            self.assertFalse(hosts.has_pair('10.10.10.10', 'Salt3'))
Exemple #7
0
 def test_set_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     set_host.hosts_filename = tmp
     assert set_host('192.168.1.123', 'newip')
     self.assertTrue(has_pair('192.168.1.123', 'newip'))
     self.assertEqual(len(list_hosts()), 7)
     assert set_host('127.0.0.1', 'localhost')
     self.assertFalse(has_pair('127.0.0.1', 'myname'), 'should remove second entry')
Exemple #8
0
 def test_set_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     set_host.hosts_filename = tmp
     assert set_host('192.168.1.123', 'newip')
     self.assertTrue(has_pair('192.168.1.123', 'newip'))
     self.assertEqual(len(list_hosts()), 7)
     assert set_host('127.0.0.1', 'localhost')
     self.assertFalse(has_pair('127.0.0.1', 'myname'),
                      'should remove second entry')
Exemple #9
0
    def test_has_pair(self):
        """
        Tests return True / False if the alias is set
        """
        with patch(
                "salt.modules.hosts._list_hosts",
                MagicMock(return_value={"10.10.10.10": ["Salt1", "Salt2"]}),
        ):
            self.assertTrue(hosts.has_pair("10.10.10.10", "Salt1"))

            self.assertFalse(hosts.has_pair("10.10.10.10", "Salt3"))
Exemple #10
0
 def test_add_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     add_host.hosts_filename = tmp
     assert add_host('192.168.1.123', 'newip')
     self.assertTrue(has_pair('192.168.1.123', 'newip'))
     self.assertEqual(len(list_hosts()), 7)
     assert add_host('127.0.0.1', 'othernameip')
     self.assertEqual(len(list_hosts()), 7)
Exemple #11
0
 def test_add_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     add_host.hosts_filename = tmp
     assert add_host('192.168.1.123', 'newip')
     self.assertTrue(has_pair('192.168.1.123', 'newip'))
     self.assertEqual(len(list_hosts()), 7)
     assert add_host('127.0.0.1', 'othernameip')
     self.assertEqual(len(list_hosts()), 7)
Exemple #12
0
 def test_has_pair(self):
     list_hosts.hosts_filename = self.hostspath
     self.assertTrue(has_pair('127.0.0.1', 'myname'))
     self.assertFalse(has_pair('127.0.0.1', 'othername'))
Exemple #13
0
 def test_has_pair(self):
     list_hosts.hosts_filename = self.hostspath
     self.assertTrue(has_pair('127.0.0.1', 'myname'))
     self.assertFalse(has_pair('127.0.0.1', 'othername'))