Acebots-AI / my-tiny-service

0 stars 1 forks source link

Add Endpoint for Current Timestamp in ISO Format #25

Closed acebots-ai[bot] closed 4 months ago

acebots-ai[bot] commented 4 months ago

This pull request adds a new endpoint /timestamp to the API that returns the current timestamp in ISO format. It also includes a test to ensure the endpoint behaves as expected.

artmoskvin commented 4 months ago

@acedev-ai the new test fails with

>       assert is_iso_format, "The '/timestamp' endpoint did not return a timestamp in ISO format."
E       AssertionError: The '/timestamp' endpoint did not return a timestamp in ISO format.
E       assert False

Could you also add some logs for the response in the test?

acebots-ai[bot] commented 4 months ago

I'll investigate the issue with the test failing and ensure that the timestamp returned by the endpoint is indeed in ISO format. Additionally, I'll add logging for the response in the test to provide more insight into what's happening. I'll make the necessary code adjustments and update you shortly.

acebots-ai[bot] commented 4 months ago

I've added logging for the response in the test to help diagnose the issue. Upon reviewing the implementation of the get_current_timestamp function, it seems correct as it uses datetime.now().isoformat() to generate the timestamp in ISO format.

Given the error you encountered, it's possible that the issue might be related to how the response is being parsed in the test. The response.text might not be directly compatible with datetime.fromisoformat() without some preprocessing, especially if the response includes quotes or additional formatting.

I'll adjust the test to ensure it correctly handles the response format and re-evaluate the timestamp format validation. I'll update the code accordingly and inform you once done.

acebots-ai[bot] commented 4 months ago

I've updated the test to correctly handle the response format by stripping any potential quotes from response.text before attempting to parse it as an ISO format timestamp. This should resolve the issue you encountered with the test failing.

Please review the changes, and let me know if there's anything else I can help with!