def test_ensure_present_create_new(self, create_module, table_client):
        module = create_module(params=dict(
            instance=dict(host="my.host.name",
                          username="******",
                          password="******"),
            state="new",
            type="normal",
            requested_by=None,
            assignment_group=None,
            category=None,
            priority=None,
            risk="low",
            impact="low",
            number=None,
            sys_id=None,
            short_description="Test change request",
            description=None,
            close_code=None,
            close_notes=None,
            on_hold=None,
            hold_reason=None,
            template=None,
            other=None,
        ), )
        table_client.create_record.return_value = dict(
            state="-5",
            number="CHG0000001",
            short_description="Test change request",
            risk="4",
            impact="3",
        )

        result = change_request.ensure_present(module, table_client)

        table_client.create_record.assert_called_once()
        assert result == (
            True,
            dict(
                state="new",
                number="CHG0000001",
                short_description="Test change request",
                risk="low",
                impact="low",
            ),
            dict(
                before=None,
                after=dict(
                    state="new",
                    number="CHG0000001",
                    short_description="Test change request",
                    risk="low",
                    impact="low",
                ),
            ),
        )
    def test_ensure_present_update(self, create_module, table_client,
                                   attachment_client):
        module = create_module(params=dict(
            instance=dict(host="my.host.name",
                          username="******",
                          password="******"),
            state="assess",
            type="normal",
            number="CHG0000001",
            requested_by=None,
            assignment_group=None,
            category=None,
            priority=None,
            risk=None,
            impact=None,
            sys_id=None,
            short_description="Test change request",
            description=None,
            close_code=None,
            close_notes=None,
            on_hold=None,
            hold_reason=None,
            template=None,
            other=None,
            attachments=None,
        ), )

        table_client.get_record.return_value = dict(
            state="-5",
            number="CHG0000001",
            chg_model="normal",
            short_description="Test change request",
            sys_id="1234",
        )
        table_client.update_record.return_value = dict(
            state="-4",
            number="CHG0000001",
            chg_model="normal",
            short_description="Test change request",
            sys_id="1234",
        )
        attachment_client.update_records.return_value = []
        attachment_client.list_records.return_value = []
        module.sha256.return_value = ""

        result = change_request.ensure_present(module, table_client,
                                               attachment_client)

        table_client.update_record.assert_called_once()
        assert result == (
            True,
            dict(
                state="assess",
                number="CHG0000001",
                chg_model="normal",
                short_description="Test change request",
                sys_id="1234",
                attachments=[],
            ),
            dict(
                before=dict(
                    state="new",
                    number="CHG0000001",
                    chg_model="normal",
                    short_description="Test change request",
                    sys_id="1234",
                    attachments=[],
                ),
                after=dict(
                    state="assess",
                    number="CHG0000001",
                    chg_model="normal",
                    short_description="Test change request",
                    sys_id="1234",
                    attachments=[],
                ),
            ),
        )