packethost / packet-python

A Python client for the Equinix Metal API
http://metal.equinix.com/
GNU Lesser General Public License v3.0
40 stars 50 forks source link

Test harness should support variable responses per API endpoint #93

Open displague opened 4 years ago

displague commented 4 years ago

The current test harness loads a fixture matching the API method and URL components. This approach is limited as there can be only one fixture per URL+method. https://github.com/packethost/packet-python/blob/master/test/test_packet.py#L226-L251

In order to test all each branch properly, expected and unexpected, sunny and rainy, responses must be provided as fixtures.

One way to get this behavior would be to hash all request parameters and append this into the fixture filename. This would make fixture creation hard because the names would not be predictable. This also wouldn't fulfill the problem because our fixtures should be able to provide various API responses given the same inputs.

A more versatile solution would be one that allows for numerous fixture responses to be defined per test or for more granularity, per API call.