-
Notifications
You must be signed in to change notification settings - Fork 163
Enhance Currency Rate Backend Error Handling & Update Tests/Settings #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ieval with error handling Improve error handling in the currency rate backend by catching JSONDecodeError and RequestException. This ensures better management of API response errors and provides meaningful error messages. test(tests/crm/backends/test_currency_rate_backend.py): add tests for currency rate backend error scenarios Implement unit tests for handling JSON decoding errors and HTTP errors in the currency rate backend. This validates that errors are captured correctly and that the backend behaves as expected under failure conditions. chore(webcrm/settings.py): enable currency exchange rate loading Set LOAD_EXCHANGE_RATE to True and specify the LOAD_RATE_BACKEND in settings to activate the currency exchange rate functionality. This allows the application to fetch and utilize currency rates as intended.
👋 Hello from RepoBird.ai!I'm the founder of RepoBird.ai, an AI Software Engineer Agent that integrates seamlessly as a GitHub App. This Pull Request was automatically generated by our agent, RepoBirdBot, to address issue #181. This issue was marked as a Why this PR?
Your Feedback Matters: Please review the proposed changes. If this type of automated contribution isn't suitable for your repository, or if this specific PR isn't helpful, just let me know! I'll close it, make any improvements and unlist these PRs – no worries. Want changes? If you have feedback or requested modifications, please leave comments directly on this PR. Once all review comments are in, comment Interested in learning more?
Thank you! |
@ariel-frischer A really great way to promote a project!
|
Gotcha, ty for the review. I'll have the bot take in the feedback and try to refactor. Any remaining issues I'll personally fix to get this PR to completion. |
…ching logic Refactor the currency rate fetching logic by introducing a private helper method `_extract_rate` to streamline error handling and improve code readability. This change simplifies the `get_marketing_currency_rate` and `get_rate_to_state_currency` methods. feat(webcrm/settings.py): enable in-memory database for testing Configure the settings to use an in-memory SQLite database when running tests. This enhances test performance by avoiding disk I/O and allows for a clean database state for each test run.
…ames for clarity fix(test_currency_rate_backend.py): remove unnecessary comments and improve readability of tests chore(settings.py): disable exchange rate loading and clear rate backend configuration for testing purposes
Ok made some updates - have not been able to run the actual test due to mysql issues on my arch system. |
This PR improves the robustness of the currency rate backend and updates the associated tests and settings.
Key changes include:
In the
crm/backends/bank_gov_ua_backend.py
module:self.error
attribute, ensuring that default values (rate = 1) are returned gracefully.get_data
while shifting error reporting to the methods that process the retrieved data.In the tests (
tests/crm/backends/test_currency_rate_backend.py
):In the settings module (
webcrm/settings.py
):LOAD_EXCHANGE_RATE
to False and clearingLOAD_RATE_BACKEND
. This prevents unexpected live API calls during test runs and allows for a controlled testing environment.These changes address issue #181 by ensuring that JSON decoding issues or request errors from the external API do not break the test suite. The backend now handles error scenarios more gracefully, and the tests confirm its behavior under failure conditions.
Created with Repobird.ai 📦🐦