class NetworkInfoTestCase(unittest.TestCase): def setUp(self): self.network_info = NetworkInfo() @patch('envoy.run') def test_no_network(self, mock_run): self.assertEqual(self.network_info.network_status(), 'No Network') mock_run.assert_any_call('iwconfig') mock_run.assert_any_call('ifconfig wlan0') mock_run.assert_any_call('ifconfig eth0') @patch('envoy.run', side_effect=[DEFAULT, DEFAULT, IFCETH0Mock]) def test_ethernet(self, mock_run): self.assertEqual(self.network_info.network_status(), '10.1.10.15') mock_run.assert_any_call('iwconfig') mock_run.assert_any_call('ifconfig wlan0') mock_run.assert_any_call('ifconfig eth0') @patch('envoy.run', side_effect=[IWCMock, IFCWLAN0Mock, IFCETH0Mock]) def test_wlan(self, mock_run): network_status = self.network_info.network_status() self.assertEqual('146csbr\n10.1.10.15', network_status) mock_run.assert_any_call('iwconfig') mock_run.assert_any_call('ifconfig wlan0') mock_run.assert_any_call('ifconfig eth0')
def setUp(self): self.network_info = NetworkInfo()