Ejemplo n.º 1
0
    def test_routes(self):
        '''
        Test for return currently configured routes from routing table
        '''
        self.assertRaises(CommandExecutionError, network.routes, 'family')

        with patch.dict(network.__grains__, {'kernel': 'A', 'os': 'B'}):
            self.assertRaises(CommandExecutionError, network.routes, 'inet')

        with patch.dict(network.__grains__, {'kernel': 'Linux'}):
            with patch.object(network,
                              '_netstat_route_linux',
                              side_effect=['A', [{
                                  'addr_family': 'inet'
                              }]]):
                with patch.object(network,
                                  '_ip_route_linux',
                                  side_effect=['A', [{
                                      'addr_family': 'inet'
                                  }]]):
                    self.assertEqual(network.routes(None), 'A')

                    self.assertListEqual(network.routes('inet'),
                                         [{
                                             'addr_family': 'inet'
                                         }])
Ejemplo n.º 2
0
    def test_routes(self):
        """
        Test for return currently configured routes from routing table
        """
        self.assertRaises(CommandExecutionError, network.routes, "family")

        with patch.dict(network.__grains__, {"kernel": "A", "os": "B"}):
            self.assertRaises(CommandExecutionError, network.routes, "inet")

        with patch.dict(network.__grains__, {"kernel": "Linux"}):
            with patch.object(
                    network,
                    "_netstat_route_linux",
                    side_effect=["A", [{
                        "addr_family": "inet"
                    }]],
            ):
                with patch.object(
                        network,
                        "_ip_route_linux",
                        side_effect=["A", [{
                            "addr_family": "inet"
                        }]],
                ):
                    self.assertEqual(network.routes(None), "A")

                    self.assertListEqual(network.routes("inet"),
                                         [{
                                             "addr_family": "inet"
                                         }])
Ejemplo n.º 3
0
    def test_routes(self):
        '''
        Test for return currently configured routes from routing table
        '''
        self.assertRaises(CommandExecutionError, network.routes, 'family')

        with patch.dict(network.__grains__, {'kernel': 'A', 'os': 'B'}):
            self.assertRaises(CommandExecutionError, network.routes, 'inet')

        with patch.dict(network.__grains__, {'kernel': 'Linux'}):
            with patch.object(network, '_netstat_route_linux',
                              side_effect=['A', [{'addr_family': 'inet'}]]):
                self.assertEqual(network.routes(None), 'A')

                self.assertListEqual(network.routes('inet'),
                                     [{'addr_family': 'inet'}])