Skip to content

Commit

Permalink
Remove unused mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
allenrobel committed Feb 21, 2024
1 parent 1be103e commit eb3bb39
Showing 1 changed file with 10 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@
responses_switch_issu_details)

PATCH_MODULE_UTILS = "ansible_collections.cisco.dcnm.plugins.module_utils."
PATCH_image_upgrade = PATCH_MODULE_UTILS + "image_upgrade."
PATCH_IMAGE_UPGRADE = PATCH_MODULE_UTILS + "image_upgrade."

PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT = (
PATCH_image_upgrade + "image_upgrade.RestSend.commit"
PATCH_IMAGE_UPGRADE + "image_upgrade.RestSend.commit"
)
PATCH_IMAGE_UPGRADE_REST_SEND_RESPONSE_CURRENT = (
PATCH_image_upgrade + "image_upgrade.RestSend.response_current"
PATCH_IMAGE_UPGRADE + "image_upgrade.RestSend.response_current"
)
PATCH_IMAGE_UPGRADE_REST_SEND_RESULT_CURRENT = (
PATCH_image_upgrade + "image_upgrade.RestSend.result_current"
PATCH_IMAGE_UPGRADE + "image_upgrade.RestSend.result_current"
)

REST_SEND_IMAGE_UPGRADE = PATCH_image_upgrade + "image_upgrade.RestSend"
DCNM_SEND_IMAGE_UPGRADE_COMMON = PATCH_image_upgrade + "image_upgrade_common.dcnm_send"
DCNM_SEND_INSTALL_OPTIONS = PATCH_image_upgrade + "install_options.dcnm_send"
DCNM_SEND_ISSU_DETAILS = PATCH_image_upgrade + "switch_issu_details.dcnm_send"
REST_SEND_IMAGE_UPGRADE = PATCH_IMAGE_UPGRADE + "image_upgrade.RestSend"
DCNM_SEND_IMAGE_UPGRADE_COMMON = PATCH_IMAGE_UPGRADE + "image_upgrade_common.dcnm_send"
DCNM_SEND_INSTALL_OPTIONS = PATCH_IMAGE_UPGRADE + "install_options.dcnm_send"
DCNM_SEND_ISSU_DETAILS = PATCH_IMAGE_UPGRADE + "switch_issu_details.dcnm_send"


def test_image_upgrade_upgrade_00001(image_upgrade) -> None:
Expand Down Expand Up @@ -207,30 +207,16 @@ def mock_dcnm_send_install_options(*args, **kwargs) -> Dict[str, Any]:
def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
return responses_switch_issu_details(key)

def mock_dcnm_send_image_upgrade_commit(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
DCNM_SEND_IMAGE_UPGRADE_COMMON, mock_dcnm_send_image_upgrade_commit
)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -451,8 +437,8 @@ def test_image_upgrade_upgrade_00021(monkeypatch, image_upgrade) -> None:
to be upgraded
- The methods called by commit are mocked to simulate that the
device has not yet been upgraded to the desired version
- Methods called by commit that wait for current actions, and
image upgrade, to complete are mocked to do nothing
- Method called by commit, _wait_for_current_actions_to_complete
is mocked to do nothing
- instance.devices is set to contain an invalid nxos.mode value
Expected results:
Expand All @@ -472,28 +458,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -729,28 +700,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -812,28 +768,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -896,28 +837,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -969,7 +895,6 @@ def test_image_upgrade_upgrade_00027(monkeypatch, image_upgrade) -> None:
instance = image_upgrade

key = "test_image_upgrade_upgrade_00027a"
image_upgrade_file = "image_upgrade_responses_ImageUpgrade"

def mock_dcnm_send_install_options(*args, **kwargs) -> Dict[str, Any]:
return responses_image_install_options(key)
Expand All @@ -980,31 +905,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1065,28 +972,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1148,28 +1040,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1231,28 +1108,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1319,28 +1181,13 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

monkeypatch.setattr(
PATCH_IMAGE_UPGRADE_REST_SEND_COMMIT, mock_rest_send_image_upgrade
)

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1403,9 +1250,6 @@ def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
return responses_image_upgrade(key)

Expand All @@ -1427,11 +1271,6 @@ def mock_rest_send_image_upgrade(*args, **kwargs) -> Dict[str, Any]:
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down Expand Up @@ -1489,30 +1328,18 @@ def test_image_upgrade_upgrade_00033(monkeypatch, image_upgrade) -> None:

key = "test_image_upgrade_upgrade_00033a"

def mock_dcnm_send_install_options(*args, **kwargs) -> Dict[str, Any]:
return responses_image_install_options(key)

def mock_dcnm_send_issu_details(*args, **kwargs) -> Dict[str, Any]:
return responses_switch_issu_details(key)

def mock_wait_for_current_actions_to_complete(*args, **kwargs):
pass

def mock_wait_for_image_upgrade_to_complete(*args, **kwargs):
pass

monkeypatch.setattr(DCNM_SEND_INSTALL_OPTIONS, mock_dcnm_send_install_options)
monkeypatch.setattr(DCNM_SEND_ISSU_DETAILS, mock_dcnm_send_issu_details)
monkeypatch.setattr(
instance,
"_wait_for_current_actions_to_complete",
mock_wait_for_current_actions_to_complete,
)
monkeypatch.setattr(
instance,
"_wait_for_image_upgrade_to_complete",
mock_wait_for_image_upgrade_to_complete,
)

instance.devices = [
{
Expand Down

0 comments on commit eb3bb39

Please sign in to comment.