Example #1
0
    def test_should_fail_when_server_hardware_type_was_not_found(self):
        self.resource.get_by.return_value = []

        self.mock_ansible_module.params = yaml.load(YAML_SERVER_HARDWARE_TYPE)

        ServerHardwareTypeModule().run()

        self.mock_ansible_module.fail_json.assert_called_once_with(
            msg=ServerHardwareTypeModule.MSG_RESOURCE_NOT_FOUND)
Example #2
0
    def test_should_remove_server_hardware_type(self):
        self.resource.get_by.return_value = [DICT_DEFAULT_SERVER_HARDWARE_TYPE]

        self.mock_ansible_module.params = yaml.load(
            YAML_SERVER_HARDWARE_TYPE_ABSENT)

        ServerHardwareTypeModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=True, msg=ServerHardwareTypeModule.MSG_DELETED)
Example #3
0
    def test_should_do_nothing_when_server_hardware_type_not_exist(self):
        self.resource.get_by.return_value = []

        self.mock_ansible_module.params = yaml.load(
            YAML_SERVER_HARDWARE_TYPE_ABSENT)

        ServerHardwareTypeModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False, msg=ServerHardwareTypeModule.MSG_ALREADY_ABSENT)
Example #4
0
    def test_should_not_update_when_data_is_equals(self):
        self.resource.get_by.return_value = [DICT_DEFAULT_SERVER_HARDWARE_TYPE]

        self.mock_ansible_module.params = yaml.load(YAML_SERVER_HARDWARE_TYPE)

        ServerHardwareTypeModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            msg=ServerHardwareTypeModule.MSG_ALREADY_PRESENT,
            ansible_facts=dict(
                server_hardware_type=DICT_DEFAULT_SERVER_HARDWARE_TYPE))
    def test_should_update_the_server_hardware_type(self):
        srv_hw_type = DICT_DEFAULT_SERVER_HARDWARE_TYPE.copy()
        srv_hw_type['uri'] = '/rest/id'

        self.resource.data = srv_hw_type

        self.mock_ansible_module.params = yaml.load(
            YAML_SERVER_HARDWARE_TYPE_CHANGE)

        ServerHardwareTypeModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=True,
            msg=ServerHardwareTypeModule.MSG_UPDATED,
            ansible_facts=dict(server_hardware_type=srv_hw_type))