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: |
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:
simple-mockforce/simple_mockforce/virtual.py
Line 289 in 1adc78e