diff options
Diffstat (limited to 'test/scenario_test/bgp_router_test.py')
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index a69aa3f7..e7ac9ec1 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -128,7 +128,7 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(interval) continue - self.assertTrue(len(global_rib) == len(self.quaggas)) + self.assertEqual(len(global_rib), len(self.quaggas)) for c in self.quaggas.itervalues(): for r in c.routes: @@ -222,21 +222,21 @@ class GoBGPTestBase(unittest.TestCase): def test_10_originate_path(self): self.gobgp.add_route('10.10.0.0/24') dst = self.gobgp.get_global_rib('10.10.0.0/24') - self.assertTrue(len(dst) == 1) - self.assertTrue(len(dst[0]['paths']) == 1) + self.assertEqual(len(dst), 1) + self.assertEqual(len(dst[0]['paths']), 1) path = dst[0]['paths'][0] - self.assertTrue(path['nexthop'] == '0.0.0.0') - self.assertTrue(len(path['aspath']) == 0) + self.assertEqual(path['nexthop'], '0.0.0.0') + self.assertEqual(len(path['aspath']), 0) def test_11_check_adj_rib_out(self): for q in self.quaggas.itervalues(): paths = self.gobgp.get_adj_rib_out(q, '10.10.0.0/24') - self.assertTrue(len(paths) == 1) + self.assertEqual(len(paths), 1) path = paths[0] peer_info = self.gobgp.peers[q] local_addr = peer_info['local_addr'].split('/')[0] - self.assertTrue(path['nexthop'] == local_addr) - self.assertTrue(path['aspath'] == [self.gobgp.asn]) + self.assertEqual(path['nexthop'], local_addr) + self.assertEqual(path['aspath'], [self.gobgp.asn]) def test_12_disable_peer(self): q1 = self.quaggas['q1'] @@ -247,13 +247,13 @@ class GoBGPTestBase(unittest.TestCase): for route in q1.routes.iterkeys(): dst = self.gobgp.get_global_rib(route) - self.assertTrue(len(dst) == 0) + self.assertEqual(len(dst), 0) for q in self.quaggas.itervalues(): if q is q1: continue paths = self.gobgp.get_adj_rib_out(q, route) - self.assertTrue(len(paths) == 0) + self.assertEqual(len(paths), 0) def test_13_enable_peer(self): q1 = self.quaggas['q1'] @@ -280,24 +280,24 @@ class GoBGPTestBase(unittest.TestCase): # iBGP peer g2 = self.quaggas['g2'] paths = g2.get_global_rib('10.20.0.0/24') - self.assertTrue(len(paths) == 1) - self.assertTrue(len(paths[0]['paths']) == 1) + self.assertEqual(len(paths), 1) + self.assertEqual(len(paths[0]['paths']), 1) path = paths[0]['paths'][0] local_pref = extract_path_attribute(path, BGP_ATTR_TYPE_LOCAL_PREF) - self.assertTrue(local_pref['value'] == 1000) + self.assertEqual(local_pref['value'], 1000) med = extract_path_attribute(path, BGP_ATTR_TYPE_MULTI_EXIT_DISC) - self.assertTrue(med['metric'] == 2000) + self.assertEqual(med['metric'], 2000) # eBGP peer q1 = self.quaggas['q1'] paths = q1.get_global_rib('10.20.0.0/24') - self.assertTrue(len(paths) == 1) + self.assertEqual(len(paths), 1) path = paths[0] local_pref = extract_path_attribute(path, BGP_ATTR_TYPE_LOCAL_PREF) # local_pref's default value is 100 - self.assertTrue(local_pref['value'] == 100) + self.assertEqual(local_pref['value'], 100) med = extract_path_attribute(path, BGP_ATTR_TYPE_MULTI_EXIT_DISC) - self.assertTrue(med['metric'] == 2000) + self.assertEqual(med['metric'], 2000) def test_17_check_shutdown(self): g1 = self.gobgp @@ -398,7 +398,7 @@ class GoBGPTestBase(unittest.TestCase): wait_for_completion(lambda: len(g2.get_global_rib(prefix)) == 0) ret = json.loads(r.next()) - self.assertTrue(ret[0]['nlri']['prefix'] == prefix) + self.assertEqual(ret[0]['nlri']['prefix'], prefix) self.assertTrue('withdrawal' in ret[0]) def test_22_check_cli_sorted(self): @@ -425,7 +425,7 @@ class GoBGPTestBase(unittest.TestCase): except StopIteration: break - self.assertTrue(cnt == cnt2) + self.assertEqual(cnt, cnt2) def test_23_check_withdrawal3(self): gobgp_ctn_image_name = parser_option.gobgp_image @@ -456,18 +456,18 @@ class GoBGPTestBase(unittest.TestCase): g4.local('gobgp global rib add 50.0.0.0/24 med 10') paths = g1.get_adj_rib_out(g3, '50.0.0.0/24') - self.assertTrue(len(paths) == 0) + self.assertEqual(len(paths), 0) paths = g1.get_adj_rib_out(g4, '50.0.0.0/24') - self.assertTrue(len(paths) == 1) - self.assertTrue(paths[0]['source-id'] == '192.168.0.8') + self.assertEqual(len(paths), 1) + self.assertEqual(paths[0]['source-id'], '192.168.0.8') g3.local('gobgp global rib del 50.0.0.0/24') paths = g1.get_adj_rib_out(g3, '50.0.0.0/24') - self.assertTrue(len(paths) == 1) - self.assertTrue(paths[0]['source-id'] == '192.168.0.9') + self.assertEqual(len(paths), 1) + self.assertEqual(paths[0]['source-id'], '192.168.0.9') paths = g1.get_adj_rib_out(g4, '50.0.0.0/24') - self.assertTrue(len(paths) == 0) + self.assertEqual(len(paths), 0) if __name__ == '__main__': |