예제 #1
0
    def test_get_ip_address(self):
        expected_ip_address = "192.168.0.126"

        platform_specifics = {
            'ANGSTROM': {
                'operating_system': {
                    'ID': 'angstrom'
                },
                'ifconfig_output': ANGSTROM_IFCONFIG_OUTPUT
            },
            'DEBIAN': {
                'operating_system': {
                    'ID': 'debian'
                },
                'ifconfig_output': DEBIAN_IFCONFIG_OUTPUT
            }
        }
        for platform, details in platform_specifics.items():
            with mock.patch.object(subprocess, 'check_output', return_value=details['ifconfig_output']),\
                 mock.patch.object(System, 'get_operating_system', return_value=details['operating_system']):
                ip_address = System.get_ip_address()
                self.assertEqual(expected_ip_address, ip_address)
예제 #2
0
 def get_local_ip_address(self):
     """ Get the local ip address. """
     _ = self  # Needs to be an instance method
     return System.get_ip_address()
예제 #3
0
 def get_local_ip_address(self):
     """ Get the local ip address. """
     _ = self  # Needs to be an instance method
     return System.get_ip_address()