def requested_srconfig(self): routes = [ IPRouteData( to='0.0.0.0/0', via=self._gateway, family=4, device=self.device, table=self._table, ), IPRouteData( to=self._network, via=self._ipaddr, family=4, device=self.device, table=self._table, ), ] rules = [ IPRuleData(src=self._network, table=self._table, prio=RULE_PRIORITY), IPRuleData( to=self._network, table=self._table, iif=self.device, prio=RULE_PRIORITY, ), ] return routes, rules
def test_add_delete_and_read_route(self): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='lo') with self.create_route(route): routes = [r for r in IPRouteTest.IPRoute.routes(table='main') if r.to == IPV4_ADDRESS] self.assertEqual(1, len(routes)) self.assertEqual(routes[0].device, 'lo') self.assertEqual(routes[0].table, 'main')
def test_add_delete_and_read_route(self, ip_route_driver): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='lo') with self._create_route(ip_route_driver, route): routes = [ r for r in ip_route_driver.routes(table='main') if r.to == IPV4_ADDRESS ] assert len(routes) == 1 assert routes[0].device == 'lo' assert routes[0].table == 'main'
def test_add_route_with_non_existing_device(self): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='NoNe') with self.assertRaises(IPRouteAddError): IPRouteTest.IPRoute.add(route)
def test_delete_non_existing_route(self): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='lo') with self.assertRaises(IPRouteDeleteError): IPRouteTest.IPRoute.delete(route)
def test_add_route_with_non_existing_device(self, ip_route_driver): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='NoNe') with pytest.raises(IPRouteAddError): ip_route_driver.add(route)
def test_delete_non_existing_route(self, ip_route_driver): route = IPRouteData(to=IPV4_ADDRESS, via=None, family=4, device='lo') with pytest.raises(IPRouteDeleteError): ip_route_driver.delete(route)