Skip to content
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

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Mar 11, 2024

Teach mock-github to write a log of POST requests, and add some initial assertions. They are not very precise yet (that'll get cleaned up in the Python rewrite soon), but at least ensure that we post the statuses to the expected SHA.

This enables us to create an integration test for a cross-project test in a future commit.

Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. Usual suggestions below.

I'm also not a fan of the tone of the second paragraph of the commit message (although this is something I feel like I've been guilty of in the past). It's not immediately clear to me if the commit in question is doing the thing that it's talking about or just "enabling" it (with the expectation that it will be done in a future commit).

@@ -39,6 +40,10 @@ class Handler(MockHandler):
self.send_error(404, 'Mock Not Found: ' + self.path)

def do_POST(self):
if log:
print("POST", self.path, self.rfile.read1().decode(), file=log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...why not (also) GET?

Copy link
Member Author

Choose a reason for hiding this comment

The 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 do_GET handles in the test, and they are also somewhat of an implementation detail. I can add them to the log of course, but I wouldn't have anything to assert on them. For human inspection it's nice though, I agree.

Added.

@@ -39,6 +40,10 @@ class Handler(MockHandler):
self.send_error(404, 'Mock Not Found: ' + self.path)

def do_POST(self):
if log:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... is not None

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -19,6 +19,7 @@ from task.test_mock_server import MockHandler, MockServer

repo = None
sha = None
log = None
Copy link
Member

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...

Copy link
Member Author

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.

Teach `mock-github` to write a log of POST requests, and add some
initial assertions. They are not very precise yet (that'll get cleaned
up in the Python rewrite soon), but at least ensure that we post the
statuses to the expected SHA.

This enables us to create an integration test for a cross-project test
in a future commit.
@martinpitt
Copy link
Member Author

@allisonkarlitskaya Reworded the commit message and fixed some of your suggestions. Thanks!

@allisonkarlitskaya allisonkarlitskaya merged commit acb2649 into main Mar 11, 2024
3 checks passed
@allisonkarlitskaya allisonkarlitskaya deleted the test-statuses branch March 11, 2024 10:52
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.

2 participants