Skip to content

Conversation

@TerryCM
Copy link

@TerryCM TerryCM commented Nov 18, 2024

This pull request includes updates to the heyoo library to enhance the reliability of HTTP requests by implementing retry logic and updating the base URLs. Additionally, new tests have been added to ensure the retry mechanism works correctly.

Enhancements to HTTP requests:

Base URL updates:

  • heyoo/__init__.py: Updated base_url and v15_base_url to use version v21.0 of the Graph API.

Testing enhancements:

  • tests/test_sending_audio.py, tests/test_sending_button.py, tests/test_sending_document.py, tests/test_sending_image.py, tests/test_sending_location.py: Added imports for requests, HTTPAdapter, Retry, and patch. Added new tests to verify retry logic by mocking requests.Session.send and asserting the correct number of retries. [1] [2] [3] [4] [5] [6] [7] [8] [9]

* **Imports**
  - Import `Retry` and `HTTPAdapter` from `requests.adapters`.

* **Session with retries**
  - Add `_get_session_with_retries` method to create a session with retry logic.

* **Update methods**
  - Update `send_message`, `send_audio`, `send_image`, `send_video`, and other methods to use the session with retry logic.
* **test_sending_audio.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_audio_retries` to check retry logic for `send_audio` method

* **test_sending_button.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_button_retries` to check retry logic for `send_button` method

* **test_sending_document.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_document_retries` to check retry logic for `send_document` method

* **test_sending_image.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_image_retries` to check retry logic for `send_image` method

* **test_sending_location.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_location_retries` to check retry logic for `send_location` method

* **test_sending_message.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_message_retries` to check retry logic for `send_message` method

* **test_sending_template_message.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_template_retries` to check retry logic for `send_template` method

* **test_sending_video.py**
  - Import `requests`, `HTTPAdapter`, `Retry`, and `patch`
  - Add `test_send_video_retries` to check retry logic for `send_video` method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant