def test_nm_connection_lifetime(self): nm_act_cons = NMDbusActiveConnections() nm_device = NMDbusDevice() iface = iface_name() with nm_connections(iface, IPV4ADDR): active_con_path = nm_device.device(iface).active_connection_path active_con = nm_act_cons.connection(active_con_path) self.assertEqual(TEST_LINK_TYPE, str(active_con.type)) self.assertEqual(types.NMActiveConnectionState.ACTIVATED, active_con.state) self._assert_no_device(iface)
def test_nm_connection_lifetime(self): nm_act_cons = NMDbusActiveConnections() nm_device = NMDbusDevice() iface = iface_name() with dummy_devices(1) as nics: with nm_connections(iface, IPV4ADDR, slaves=nics): device = nm_device.device(iface) active_con_path = device.active_connection_path active_con = nm_act_cons.connection(active_con_path) self.assertEqual(TEST_LINK_TYPE, str(active_con.type)) self.assertEqual(types.NMActiveConnectionState.ACTIVATED, active_con.state) self._assert_no_device(iface)
def test_nm_connection_lifetime(self): nm_act_cons = NMDbusActiveConnections() nm_device = NMDbusDevice() iface = iface_name() with dummy_devices(1) as nics: with nm_connections(iface, IPV4ADDR, slaves=nics): device = nm_device.device(iface) device.syncoper.waitfor_activated_state() active_con_path = device.active_connection_path() active_con = nm_act_cons.connection(active_con_path) self.assertEqual(TEST_LINK_TYPE, str(active_con.type())) self.assertEqual(types.NMActiveConnectionState.ACTIVATED, active_con.state()) self._assert_no_device(iface)
def _test_device_with_n_connections(self, con_count): nm_device = NMDbusDevice() nm_settings = NMDbusSettings() nm_act_cons = NMDbusActiveConnections() configured_connections = set() active_connections = set() iface = iface_name() with nm_connections(iface, IPV4ADDR, con_count=con_count): device = nm_device.device(iface) for connection_path in device.connections_path: settings_con = nm_settings.connection(connection_path) configured_connections.add(settings_con.connection.id) ac = nm_act_cons.connection(device.active_connection_path) active_connections.add(ac.id) self.assertEqual(con_count, len(configured_connections)) self.assertEqual(set([iface + '0']), active_connections)
def _test_device_with_n_connections(self, con_count): nm_device = NMDbusDevice() nm_settings = NMDbusSettings() nm_act_cons = NMDbusActiveConnections() configured_connections = set() active_connections = set() iface = iface_name() with dummy_devices(1) as nics: with nm_connections( iface, IPV4ADDR, slaves=nics, con_count=con_count ): device = nm_device.device(iface) for connection_path in device.connections_path(): settings_con = nm_settings.connection(connection_path) configured_connections.add(settings_con.connection.id) ac = nm_act_cons.connection(device.active_connection_path()) active_connections.add(ac.id()) self.assertEqual(con_count, len(configured_connections)) self.assertEqual(set([iface + '0']), active_connections)
def _assert_no_device(self, iface): nm_device = NMDbusDevice() with self.assertRaises(NMDeviceNotFoundError): nm_device.device(iface)