Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map versioned client names to versioned fixtures
When mapping client objects (by name) to directories in the _testing data modules, the current mapping inspects `service_name` and the method name. As a result, it's not possible to have multiple versioned clients with the same service name mapped to different fixture directories. To resolve, we need *some* solution which maps versioned clients to versioned fixtures. This change applies one particular solution, which will work in the near-term for ComputeClientV2 and ComputeClientV3, but may be refined further in the future (so long as the mapping of the V2 client to known fixture data is preserved). Rather than ignoring the possibility of structured information in the name of a client, if it ends with `V<N>` for some integer `N`, we can map this to a fixture dir named, similarly, `v<N>` (lowercased). This allows the V2 and V3 clients to get their own fixture directories. One downside of this approach is that it maps `ComputeClient` (which inherits from the V2 client) differently from `ComputeClientV2`, and there is no step here taken to rectify this. Effectively, this means that `ComputeClient` will get no fixture data, but `ComputeClientV2` will, even for identical usages. Alternative approaches abound -- e.g., we could attach a class-level attribute which declares a "test_fixture_subdir" or "api_version", and use that attribute when present. The current solution was chosen as - generic, in that it does not encode Compute-specific details into a helper buried in `_testing` - easy to implement and reason about (it's just a quick suffix match and string conversion) - easy to change or replace in the future, because it makes no changes to the classes which are fed into this mapping
- Loading branch information