pulp_2_tests.tests.platform.api_v2.test_search¶
Location: Pulp 2 Tests → Tests → pulp_2_tests.tests.platform.api_v2.test_search
Test Pulp’s Searching facilities.
The tests in this module make use of the User APIs. However, few user-specific references are made. These tests could be rewritten to use repositories or something else with only minimal changes. Thus, the name of this module.
Each test case executes one or more pairs of semantically identical POST and GET requests. Each pair of search results should match exactly.
Most test cases assume that the assertions in some other test case hold true. The assumptions explored in this module have the following dependencies:
It is possible to ask for all resources of a kind.
├── It is possible to sort search results.
├── It is possible to ask for a single field in search results.
├── It is possible to ask for several fields in search results.
└── It is possible to ask for a resource with a specific ID.
└── It is possible to ask for a resource with one of several IDs.
├── It is possible to skip some search results.
└── It is possible to limit how many search results are returned.
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
FieldTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for a single field in search results.
GET {'field': 'name'}
(urlencoded)POST {'criteria': {'fields': 'name'}}
-
classmethod
setUpClass
()¶ Create one user. Execute searches.
-
test_field
()¶ Only the requested key should be in each response.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
FieldsTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for several fields in search results.
GET field=login&field=roles
POST {'criteria': {'fields': ['login', 'roles']}}
-
classmethod
setUpClass
()¶ Create one user. Execute searches.
-
test_fields
()¶ Only the requested keys should be in each response.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
FiltersIdTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for a resource with a specific ID.
There is no specification for executing these searches with GET.
GET {'filters': {'id': '…'}}
(urlencoded)POST {'criteria': {'filters': {'id': '…'}}}
-
classmethod
setUpClass
()¶ Search for exactly one user.
-
test_result_ids
()¶ Assert the search results contain the correct IDs.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
FiltersIdsTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for resources with one of several IDs.
There is no specification for executing these searches with GET.
GET {'filters': {'id': {'$in': ['…', '…']}}}
POST {'criteria': {'filters': {'id': {'$in': ['…', '…']}}}}
-
classmethod
setUpClass
()¶ Search for exactly two users.
-
test_result_ids
()¶ Assert the search results contain the correct IDs.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
LimitSkipTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for search results to be limited or skipped.
There is no specification for executing these searches with GET.
GET {'filters': {'id': {'$in': [id1, id2]}}, 'limit': 1}
GET {'filters': {'id': {'$in': [id1, id2]}}, 'skip': 1}
POST {'criteria': {'filters': {'id': {'$in': [id1, id2]}}, 'limit': 1}}
POST {'criteria': {'filters': {'id': {'$in': [id1, id2]}}, 'skip': 1}}
-
classmethod
setUpClass
()¶ Create two users. Execute searches.
-
test_results
()¶ Check that one of the two created users has been found.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
MinimalTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for all resources of a certain kind.
GET no query parameters POST {'criteria': {}}
-
classmethod
setUpClass
()¶ Create one user. Execute searches.
-
test_user_found
()¶ Assert each search result should include a user we created.
-
classmethod
-
class
pulp_2_tests.tests.platform.api_v2.test_search.
SortTestCase
(*args, **kwargs)¶ Bases:
pulp_2_tests.tests.platform.api_v2.test_search._BaseTestCase
Ask for sorted search results.
There is no specification for executing these searches with GET.
POST {'criteria': {'sort': [['id', 'ascending']]}}
POST {'criteria': {'sort': [['id', 'descending']]}}
-
classmethod
setUpClass
()¶ Create two users. Execute searches.
-
test_ascending
()¶ Assert ascending results are ordered from low to high.
-
test_descending
()¶ Assert descending results are ordered from high to low.
-
classmethod
-
pulp_2_tests.tests.platform.api_v2.test_search.
setUpModule
()¶ Create several users, each with a randomized login name.
Test cases may search for these users or otherwise perform non-destructive actions on them. Test cases should not change these users.
-
pulp_2_tests.tests.platform.api_v2.test_search.
tearDownModule
()¶ Delete the users created by
setUpModule()
.