コード例 #1
0
ファイル: network_test.py プロジェクト: m-lab/collectd-mlab
    def test_get_uplink_mac_raises_NoDefaultGateway_when_gateway_is_empty(
            self, mock_gateways):
        mock_gateways.return_value = {}
        mock_arp_cache = mock.Mock(spec=arp.ArpCache)
        mock_arp_cache.ip_to_mac.side_effect = Exception(
            'Should not be called.')

        with self.assertRaises(network.NoDefaultGateway):
            network.get_uplink_mac(mock_arp_cache)
コード例 #2
0
    def test_get_uplink_mac_raises_NoDefaultGateway_when_gateway_is_empty(
            self, mock_gateways):
        mock_gateways.return_value = {}
        mock_arp_cache = mock.Mock(spec=arp.ArpCache)
        mock_arp_cache.ip_to_mac.side_effect = Exception(
            'Should not be called.')

        with self.assertRaises(network.NoDefaultGateway):
            network.get_uplink_mac(mock_arp_cache)
コード例 #3
0
ファイル: network_test.py プロジェクト: m-lab/collectd-mlab
    def test_get_uplink_mac(self, mock_gateways):
        mock_gateways.return_value = {
            'default': {route.AF_INET: ('5.4.3.2', 'eth0')}
        }
        mock_arp_cache = mock.Mock(spec=arp.ArpCache)
        mock_arp_cache.ip_to_mac.return_value = '00:11:22:33:44:55'

        actual_mac = network.get_uplink_mac(mock_arp_cache)

        self.assertEqual('00:11:22:33:44:55', actual_mac)
        mock_arp_cache.ip_to_mac.assert_called_once_with('5.4.3.2')
コード例 #4
0
    def test_get_uplink_mac(self, mock_gateways):
        mock_gateways.return_value = {
            'default': {
                route.AF_INET: ('5.4.3.2', 'eth0')
            }
        }
        mock_arp_cache = mock.Mock(spec=arp.ArpCache)
        mock_arp_cache.ip_to_mac.return_value = '00:11:22:33:44:55'

        actual_mac = network.get_uplink_mac(mock_arp_cache)

        self.assertEqual('00:11:22:33:44:55', actual_mac)
        mock_arp_cache.ip_to_mac.assert_called_once_with('5.4.3.2')