-
Notifications
You must be signed in to change notification settings - Fork 35
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
tasks: Test posted statuses in mock PR and image refresh #592
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 |
---|---|---|
|
@@ -19,10 +19,15 @@ from task.test_mock_server import MockHandler, MockServer | |
|
||
repo = None | ||
sha = None | ||
log = None | ||
|
||
|
||
class Handler(MockHandler): | ||
def do_GET(self): | ||
if log is not None: | ||
print("GET", self.path, file=log) | ||
log.flush() | ||
|
||
if self.path in self.server.data: | ||
self.replyJson(self.server.data[self.path]) | ||
elif self.path.startswith(f'/repos/{repo}/pulls?'): | ||
|
@@ -39,6 +44,10 @@ class Handler(MockHandler): | |
self.send_error(404, 'Mock Not Found: ' + self.path) | ||
|
||
def do_POST(self): | ||
if log is not None: | ||
print("POST", self.path, self.rfile.read1().decode(), file=log) | ||
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. ...why not (also) GET? 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. This is mostly meant to validate actions. GET requests don't change the state, they are already sufficiently defined in terms of which paths Added. |
||
log.flush() | ||
|
||
if self.path.startswith(f'/repos/{repo}/statuses/{sha}'): | ||
self.replyJson({}) | ||
# new SHA from mock-pushed PR #2 for image-refresh | ||
|
@@ -63,6 +72,7 @@ argparser.add_argument('--print-pr-event', action='store_true', | |
help="Print GitHub webhook pull_request event and exit") | ||
argparser.add_argument('--print-image-refresh-event', action='store_true', | ||
help="Print GitHub webhook issue event for an image-refresh and exit") | ||
argparser.add_argument('--log', metavar="PATH", help="Log requests to this file") | ||
argparser.add_argument('repo', metavar='USER/PROJECT', help="GitHub user/org and project name") | ||
argparser.add_argument('sha', help="SHA to test in repo for the mock PR") | ||
args = argparser.parse_args() | ||
|
@@ -125,6 +135,8 @@ if args.print_image_refresh_event: | |
}, indent=4)) | ||
exit(0) | ||
|
||
if args.log: | ||
log = open(args.log, 'w') | ||
temp = tempfile.TemporaryDirectory() | ||
cache_dir = os.path.join(temp.name, 'cache') | ||
os.environ['XDG_CACHE_HOME'] = cache_dir | ||
|
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.
I wonder if you'd like to add some more types...
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.
TBH not today when we have a crapton of stuff to catch up with. I'd like to reserve this to the next weeks -- I also want to rewrite run-local.sh as proper pytest.