Use different User-Agent for test runs
In astroquery we add "testrun" to the end of the version string that is being used in the request's header'User-Agent' to distinguish tests from user usage.
I've tried to do the same solution here, but the utils.http is imported/set as part of an "import pyvo" earlier than the test runner could kick in executing conftest. ~A hacky workaround is to delay the import, I'll add that hack to #145~ the hack is not working, and anyway it's better to keep the cleanup PR focused on cleanup.
On Wed, Jun 05, 2019 at 12:15:57AM -0700, Brigitta Sipocz wrote:
In astroquery we add "testrun" to the end of the version string that is being used in the request's header
'User-Agent'to distinguish tests from user usage.
Tangentially related it might be a good idea to think about if/how pyVO could somehow offer some support for the informal agreement on user agents for "infrastructure" requests as laid down on https://wiki.ivoa.net/twiki/bin/view/IVOA/UserAgentUsage.
An API I could totally see would be a context manager like
with pyvo.useragent("{pyvo-signature} (IVOA-harvest_obscore)"
" {python-version}"):
stuff
(where we'd need to think of keys that make sense for string interpolation in there).
I suppose one could even hack the test harness to control the user agent in this way -- but I've not had a look at the code.
How to change the User Agent is described in https://github.com/astropy/pyvo/issues/107
Yes, the thing is that ideally it should be changeable from the test configs (e.g changing the version number that is currently being used, like we do it from astroquery). Anyway, I won't have time to sort this out, just leave the issue open that this needs to be sorted out.
Do the tests we run actually use the network? My understanding was these are all local tests using xml files for responses that are checked in.
Agree, fixing the user agent for test runs on the network and making that work will be good though, especially if people build clients on top of pyvo.
Oh, that's a good point, they indeed don't use the network. But at some point it may make sense to add a few remote tests, too?
Yeah I would love to test against the network more often, and it looks like there are some remote tests mentioned in the README, but at least we're not filling people's logs with our test runs just yet.
but at least we're not filling people's logs with our test runs just yet.
yes, that's definitely needs to be thought about how to do well, remote tests should not really run for all commits in all PRs.