QuTech-Delft / quantuminspire

Quantum Inspire SDK
Apache License 2.0
65 stars 27 forks source link

[SDS-316] Append a trailing slash to the base_url if it's missing #138

Closed tomrijnbeek closed 2 years ago

tomrijnbeek commented 2 years ago

This PR updates the behaviour of QuantumInspireAPI to always normalize the base_url by adding a trailing slash if it is missing. The reason this is necessary is because urljoin rewrites the last part of the URL path if it doesn't terminate in a slash, as it interprets it as a file rather than a directory [1].

The tests for the QuantumInspireAPI implicitly relied on this behaviour, expecting FakeURL to be rewritten to schema/, whereas the correct URL would be FakeURL/schema/. The tests have been fixed to remove this inconsistency, as well as new tests to verify the behaviour both with and without trailing slash.

NOTE: this is a potentially breaking change if clients depend on the rewriting behaviour of urljoin in their use of the API object.

[1] https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling e581534aefee1dd6f731ca0a338406d93f2e65d4 on fix/SDS-316/trailing-slash into 30232955eb9db42b7860260c27e3d52e32aa73e9 on dev.