Esempio n. 1
0
 def test_parse_route_with_proto_and_metric(self):
     network = factory.make_ipv4_network()
     subnet = str(network.cidr)
     gateway = factory.pick_ip_in_network(network)
     interface = factory.make_name("nic")
     proto = factory.make_name("proto")
     metric = random.randint(50, 100)
     route_line = "%s via %s dev %s proto %s metric %d" % (
         subnet,
         gateway,
         interface,
         proto,
         metric,
     )
     self.assertEquals(
         (
             subnet,
             {
                 "via": gateway,
                 "dev": interface,
                 "proto": proto,
                 "metric": metric,
             },
         ),
         _parse_route_definition(route_line),
     )
Esempio n. 2
0
 def test_parse_route_without_proto_or_metric(self):
     network = factory.make_ipv4_network()
     subnet = str(network.cidr)
     gateway = factory.pick_ip_in_network(network)
     interface = factory.make_name("nic")
     route_line = "%s via %s dev %s" % (subnet, gateway, interface)
     self.assertEquals(
         (subnet, {"via": gateway, "dev": interface}),
         _parse_route_definition(route_line),
     )