-
Notifications
You must be signed in to change notification settings - Fork 0
#160 - Update to latest version of PyGitHub #161
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
import time | ||
|
||
from datetime import datetime | ||
from datetime import datetime, timedelta | ||
|
||
import pytest | ||
|
||
|
@@ -26,7 +26,7 @@ | |
from github.Issue import Issue | ||
from github.PullRequest import PullRequest | ||
from github.Rate import Rate | ||
from github.RateLimit import RateLimit | ||
from github.RateLimitOverview import RateLimitOverview | ||
from github.Repository import Repository | ||
|
||
from release_notes_generator.model.issue_record import IssueRecord | ||
|
@@ -112,14 +112,11 @@ def rate_limiter(mocker, request): | |
@pytest.fixture | ||
def mock_rate_limiter(mocker): | ||
mock_rate = mocker.Mock(spec=Rate) | ||
mock_rate.timestamp = mocker.Mock(return_value=time.time() + 3600) | ||
|
||
mock_core = mocker.Mock(spec=RateLimit) | ||
mock_core.reset = mock_rate | ||
mock_rate.reset = datetime.now() + timedelta(hours=1) | ||
|
||
mock = mocker.Mock(spec=GithubRateLimiter) | ||
mock.core = mock_core | ||
mock.core.remaining = 10 | ||
mock.rate = mock_rate | ||
mock.rate.remaining = 10 | ||
|
||
Comment on lines
+115
to
120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainMock the right spec and prefer core. Return a RateLimit-like object from get_rate_limit(), not a GithubRateLimiter mock. Also align on core.*. - mock_rate = mocker.Mock(spec=Rate)
- mock_rate.reset = datetime.now() + timedelta(hours=1)
-
- mock = mocker.Mock(spec=GithubRateLimiter)
- mock.rate = mock_rate
- mock.rate.remaining = 10
+ mock_rate = mocker.Mock(spec=Rate)
+ mock_rate.reset = datetime.now() + timedelta(hours=1)
+
+ # This object mimics github.RateLimit.RateLimit
+ from github.RateLimit import RateLimit # optional: type hint only
+ mock = mocker.Mock() # don’t use GithubRateLimiter as spec here
+ mock.core = mock_rate
+ mock.core.remaining = 10 Run to catch stray usages: 🏁 Script executed: #!/bin/bash
rg -nP '\.get_rate_limit\(\)\.rate\b|\.rate\.(remaining|reset)\b' Length of output: 1782 Mock Replace all occurrences of
Ensure 🤖 Prompt for AI Agents
|
||
return mock | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid import: RateLimitOverview doesn’t exist in PyGithub.
Docs and sources reference github.RateLimit.RateLimit; there’s no RateLimitOverview class to import. This will fail at import time. (pygithub.readthedocs.io, github.com)
📝 Committable suggestion
🤖 Prompt for AI Agents