Exemplo n.º 1
0
    def test_should_do_nothing_when_resource_not_exist(self):
        self.resource.get_by.return_value = []
        self.mock_ansible_module.params = PARAMS_FOR_ABSENT

        SasLogicalInterconnectGroupModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            msg=SasLogicalInterconnectGroupModule.MSG_ALREADY_ABSENT)
Exemplo n.º 2
0
    def test_should_remove(self):
        self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]

        self.mock_ansible_module.params = PARAMS_FOR_ABSENT

        SasLogicalInterconnectGroupModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=True, msg=SasLogicalInterconnectGroupModule.MSG_DELETED)
Exemplo n.º 3
0
    def test_should_not_update_when_data_is_equals(self):
        self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]

        self.mock_ansible_module.params = PARAMS_FOR_PRESENT

        SasLogicalInterconnectGroupModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            msg=SasLogicalInterconnectGroupModule.MSG_ALREADY_PRESENT,
            ansible_facts=dict(
                sas_logical_interconnect_group=DEFAULT_SAS_LIG_TEMPLATE))
Exemplo n.º 4
0
    def test_create_with_newName_when_resource_not_exists(self):
        data_merged = DEFAULT_SAS_LIG_TEMPLATE.copy()
        data_merged['name'] = RENAMED_SAS_LIG
        params_to_rename = PARAMS_TO_RENAME.copy()

        self.resource.get_by.return_value = []
        self.resource.create.return_value = DEFAULT_SAS_LIG_TEMPLATE

        self.mock_ansible_module.params = params_to_rename

        SasLogicalInterconnectGroupModule().run()

        self.resource.create.assert_called_once_with(PARAMS_TO_RENAME['data'])
Exemplo n.º 5
0
    def test_should_create(self):
        self.resource.get_by.return_value = []
        self.resource.create.return_value = DEFAULT_SAS_LIG_TEMPLATE

        self.mock_ansible_module.params = PARAMS_FOR_PRESENT

        SasLogicalInterconnectGroupModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=True,
            msg=SasLogicalInterconnectGroupModule.MSG_CREATED,
            ansible_facts=dict(
                sas_logical_interconnect_group=DEFAULT_SAS_LIG_TEMPLATE))
    def test_rename_when_resource_exists(self):
        data_merged = DEFAULT_SAS_LIG_TEMPLATE.copy()
        data_merged['name'] = RENAMED_SAS_LIG
        params_to_rename = PARAMS_TO_RENAME.copy()

        self.resource.data = DEFAULT_SAS_LIG_TEMPLATE
        self.resource.update.return_value = data_merged

        self.mock_ansible_module.params = params_to_rename

        SasLogicalInterconnectGroupModule().run()

        self.resource.update.assert_called_once_with(data_merged)
Exemplo n.º 7
0
    def test_update_when_data_has_modified_attributes(self):
        data_merged = DEFAULT_SAS_LIG_TEMPLATE.copy()
        data_merged['description'] = 'New description'

        self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]
        self.resource.update.return_value = data_merged

        self.mock_ansible_module.params = PARAMS_WITH_CHANGES

        SasLogicalInterconnectGroupModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=True,
            msg=SasLogicalInterconnectGroupModule.MSG_UPDATED,
            ansible_facts=dict(sas_logical_interconnect_group=data_merged))