ansible/test
Adrian Likins af01cb114c
Support galaxy v3/autohub API in ansible-galaxy (#60982)
* Add galaxy collections API v3 support

Issue: ansible/galaxy-dev#60

- Determine if server supports v3

Use 'available_versions' from `GET /api`
to determine if 'v3' api is available on
the server.

- Support v3 pagination style

ie, 'limit/offset style', with the paginated
responses based on https://jsonapi.org/format/#fetching-pagination

v2 galaxy uses pagination that is more or less
'django rest framework style' or 'page/page_size style',
based on the default drf pagination described
at https://www.django-rest-framework.org/api-guide/pagination/#pagenumberpagination

- Support galaxy v3 style error response

The error objects returned by the galaxy v3 api are based
on the JSONAPI response/errors format
(https://jsonapi.org/format/#errors).

This handles that style response. At least for publish_collection
for now. Needs extracting/generalizing.

Handle HTTPError in CollectionRequirement.from_name()
with _handle_http_error(). It will raise AnsibleError
based on the json in an error response.

- Update unit tests

update test/unit/galaxy/test_collection*
to paramaterize calls to test against
mocked v2 and v3 servers apis.

Update artifacts_versions_json() to tale an
api version paramater.

Add error_json() for generating v3/v3 style error
responses.

So now, the urls generated and the pagination schema
of the response will use the v3 version if
the passed in GalaxyAPI 'galaxy_api' instance
has 'v3' in it's available_api_versions

* Move checking of server avail versions to collections.py

collections.py needs to know the server api versions
supported before it makes collection related calls,
so the 'lazy' server version check in api.GalaxyAPI
is never called and isn't set, so 'v3' servers weren't
found.

Update unit tests to mock the return value of the
request instead of GalaxyAPI itself.
2019-08-28 16:59:34 -04:00
..
ansible_test Relocate ansible-test self tests outside package. (#61255) 2019-08-24 11:38:30 -07:00
integration Resource Module for exos_lldp_global (#60988) 2019-08-28 13:58:45 -04:00
legacy Online: rename _facts -> _info (#61091) 2019-08-27 16:36:55 -04:00
lib/ansible_test Attempt quick fix for CI failures. 2019-08-28 09:42:23 -07:00
sanity oVirt: rename _facts -> _info (#61299) 2019-08-28 21:01:46 +02:00
units Support galaxy v3/autohub API in ansible-galaxy (#60982) 2019-08-28 16:59:34 -04:00
utils Fix CI test result placement. 2019-08-28 09:58:00 -07:00