Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewiebe committed Nov 14, 2024
1 parent 671ab98 commit a3da494
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/module_utils/network/dcnm/dcnm_vpc_pair_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def dcnm_vpc_pair_utils_get_vpc_pair_info_from_dcnm(self, swid):
# Get useVirtualPeerlink information
path = self.paths["VPC_PEER_LINK_GET_PATH"]
path = path.format(peerOneId)

resp = dcnm_send(self.module, "GET", path)

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,32 @@
}
},

"vpc_pair_info_virtual_peer_link_resp":
{
"DATA": [{
"blockSelection": "False",
"currentPeer": "True",
"ethSwitchId": 178800,
"fabricName": "None",
"ipAddress": "172.31.217.103",
"lanId": 0,
"logicalName": "93180YC-FX3S-L1-S1",
"nxosVersion": "10.4(3)",
"platformType": "None",
"recommendationReason": "Switches have same role and support Virtual Fabric Peering",
"recommended": "True",
"serialNumber": "FDO24020JMT",
"useVirtualPeerlink": "False",
"uuid": "None",
"vdcId": 0,
"vdcName": "None"
}],
"MESSAGE": "OK",
"METHOD": "GET",
"REQUEST_PATH": "https://10.78.210.227:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/vpcpair/recommendation?serialNumber=FDO24020JMB&useVirtualPeerlink=true",
"RETURN_CODE": 200
},

"vpc_pair_policy_resp_84":
{
"RETURN_CODE": 200,
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/modules/dcnm/test_dcnm_vpc_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ def test_dcnm_vpc_pair_00003(

if tc_id < 7:
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_00003"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_00003"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_00003"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_00003"))
)
Expand Down Expand Up @@ -250,22 +252,28 @@ def test_dcnm_vpc_pair_00004(
resp = load_data("dcnm_vpc_pair_response")

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_1"))
)

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_2"))
)

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_3"))
)
Expand Down Expand Up @@ -341,12 +349,15 @@ def test_dcnm_vpc_pair_00005(

if tc_id < 3:
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_2"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_3"))
elif tc_id == 3:
dcnm_send_side_effect.append([])
Expand All @@ -356,23 +367,29 @@ def test_dcnm_vpc_pair_00005(
vpc_pair.vpc_pair_info[0]["peerOneId"] = "10.122.84.190"

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_2"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_3"))
elif tc_id == 5:
vpc_pair.vpc_pair_info[0]["peerTwoId"] = "10.122.84.190"

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_2"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_3"))

update_delete_payloads_side_effect.append(
Expand Down Expand Up @@ -722,14 +739,18 @@ def test_dcnm_vpc_pair_00010(
resp = load_data("dcnm_vpc_pair_response")

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_1"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_2"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_3"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_3"))

mock_dcnm_send = Mock(side_effect=dcnm_send_side_effect)
Expand Down Expand Up @@ -778,6 +799,7 @@ def test_dcnm_vpc_pair_00010_2(
resp = load_data("dcnm_vpc_pair_response")

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))

mock_dcnm_send = Mock(side_effect=dcnm_send_side_effect)
Expand Down Expand Up @@ -823,6 +845,7 @@ def test_dcnm_vpc_pair_00010_3(
resp = load_data("dcnm_vpc_pair_response")

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_1"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_1"))

mock_dcnm_send = Mock(side_effect=dcnm_send_side_effect)
Expand Down Expand Up @@ -1912,10 +1935,13 @@ def test_dcnm_vpc_pair_merged_existing(self):

# dcnm_send() invoked from module_utils/dcnm_vpc_pair_utils.py
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_sync_status_in_sync"))
dcnm_send_side_effect.append(resp.get("vpc_pair_sync_status_in_sync"))
Expand Down Expand Up @@ -2042,10 +2068,13 @@ def test_dcnm_vpc_pair_delete_existing(self):

# dcnm_send() invoked from module_utils/dcnm_vpc_pair_utils.py
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_delete_succ_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_delete_succ_resp"))
Expand Down Expand Up @@ -2260,17 +2289,21 @@ def test_dcnm_vpc_pair_override_existing_cfg(self):
# dcnm_send() invoked from module_utils/dcnm_vpc_pair_utils.py
dcnm_send_side_effect.append(resp.get("vpc_pair_null_have"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_86"))

dcnm_send_side_effect.append(resp.get("vpc_pair_null_have"))
dcnm_send_side_effect.append(resp.get("vpc_pair_null_have"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_85"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_86"))
)
Expand Down Expand Up @@ -2389,21 +2422,27 @@ def test_dcnm_vpc_pair_override_existing_no_new_cfg(self):

# dcnm_send() invoked from module_utils/dcnm_vpc_pair_utils.py
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_86"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_84"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_85"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_86"))
)
Expand Down Expand Up @@ -2507,21 +2546,27 @@ def test_dcnm_vpc_pair_query(self):

# dcnm_send() invoked from module_utils/dcnm_vpc_pair_utils.py
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(resp.get("vpc_pair_policy_resp_86"))

dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_84"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_84"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_85"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_85"))
)
dcnm_send_side_effect.append(resp.get("vpc_pair_info_resp_86"))
dcnm_send_side_effect.append(resp.get("vpc_pair_info_virtual_peer_link_resp"))
dcnm_send_side_effect.append(
copy.deepcopy(resp.get("vpc_pair_policy_resp_86"))
)
Expand Down

0 comments on commit a3da494

Please sign in to comment.