Skip to content

Datetimes set on created objects are not timezone-aware, do not match expected Salesforce datetime format #31

Description

@perotinus

The code that handles creation of a mocked Salesforce object sets some date parameters to a naive datetime (i.e., one without a time zone). As far as I can tell, Salesforce expects datetimes to be UTC-relative, and returns datetimes in a standardized format that include the time zone (%Y-%m-%dT%H:%M:%S.%f%z) (see https://github.com/simple-salesforce/simple-salesforce?tab=readme-ov-file#helpful-datetime-resources). So, when trying to parse a datetime on an object returned from the mock that was set by the mock (e.g., CreatedDate) the date parsing fails, whereas we would never expect it to fail when hitting a real Salesforce instance.

I think the fix here would be to make the datetime used in the referenced code below a timezone-aware date with the UTC timezone. That should correctly be serialized into an ISO format date with a time zone indicator and match the Salesforce format.

Reference:

def _add_system_fields(self, sobject: dict) -> dict:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions