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

Replace localhost with constant #21

Merged
merged 1 commit into from
Aug 31, 2023
Merged

Replace localhost with constant #21

merged 1 commit into from
Aug 31, 2023

Conversation

gaul
Copy link

@gaul gaul commented Aug 21, 2023

This allows overriding a single constant when using an external httpbin. References gaul/java-httpbin#4.

@kevin1024
Copy link

Huh. How does that work? Does your test suite swap out that constant somehow? Would an env var work better?

@gaul
Copy link
Author

gaul commented Aug 21, 2023

Yeah this should be an environment variable. Would os.getenv("HTTPBIN_HOST_AND_PORT", 'localhost:80') be OK?

@kevin1024
Copy link

I'm worried that HTTPBIN_HOST_AND_PORT would indicate to a potential user that the setting will actually dictate the hostname and port of httpbin the app, when in fact it just allows a third-party test suite user to override the hostname.

Maybe there's some way to name the envvar so that it is obvious that it only affects these tests?

Maybe there's some way to rewrite the assertions so they don't care about the hostname?

Maybe your original idea was better with the contant, and then you could apply a patch before running the tests against java-httpbin?

In general, creating a test suite usable by other httpbin clones isn't exactly in scope of this project. It does seem like that would be pretty cool to be able to reuse the tests though.

@exhuma
Copy link

exhuma commented Aug 27, 2023

I'm not quite sure I understand what the link between java-httpbin and httpbin is. Is java-httpbin using Jython and import the test-cases? I've quickly skimmed the java-httpbin code and did not see any such reference.

If it's not Jython, then how is a code-change in the Python implementation going to affect java-httpbin?

@kevin1024
Copy link

seems to me it's a reimplementation of httpbin in java, and @gaul just thinks it would be cool to be able to use the python httpbin test suite to validate that the java implementation of httpbin works the same as the original python implementation. Am I on the right track @gaul?

@gaul
Copy link
Author

gaul commented Aug 29, 2023

java-httpbin is a pure Java reimplementation of httpbin. I am only using the httpbin test suite to ensure conformance.

Thanks for the suggestion to match the URL without the host! I updated the PR to match.

This allows a non-localhost to work, e.g., java-httpbin.  References
gaul/java-httpbin#4.
@exhuma
Copy link

exhuma commented Aug 29, 2023

That makes perfect sense. The new changes also look fine. They are a bit more forgiving but I'd say that's fine.

@kevin1024
Copy link

I dig it.

@kevin1024 kevin1024 merged commit ba1b151 into psf:main Aug 31, 2023
28 checks passed
@gaul gaul deleted the test/localhost branch August 31, 2023 05:01
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.

3 participants