| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import typing as t |
| 4 |
import uuid |
| 5 |
|
| 6 |
from globus_sdk.testing.models import RegisteredResponse, ResponseSet |
| 7 |
|
| 8 |
INDEX_IDS = [str(uuid.uuid1()), str(uuid.uuid1())] |
| 9 |
INDEX_ATTRIBUTES: dict[str, dict[str, t.Any]] = { |
| 10 |
INDEX_IDS[0]: { |
| 11 |
"subscription_id": None, |
| 12 |
"creation_date": "2038-07-17 16:48:24", |
| 13 |
"display_name": "Index of Indexed Awesomeness", |
| 14 |
"description": "Turbo Awesome", |
| 15 |
"max_size_in_mb": 1, |
| 16 |
"size_in_mb": 0, |
| 17 |
"num_subjects": 0, |
| 18 |
"num_entries": 0, |
| 19 |
"permissions": ["owner"], |
| 20 |
}, |
| 21 |
INDEX_IDS[1]: { |
| 22 |
"subscription_id": str(uuid.uuid1()), |
| 23 |
"creation_date": "2470-10-11 20:09:40", |
| 24 |
"display_name": "Catalog of encyclopediae", |
| 25 |
"description": "Encyclopediae from Britannica to Wikipedia", |
| 26 |
"max_size_in_mb": 100, |
| 27 |
"size_in_mb": 23, |
| 28 |
"num_subjects": 1822, |
| 29 |
"num_entries": 3644, |
| 30 |
"permissions": ["writer"], |
| 31 |
}, |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
def _make_doc(index_id: str) -> dict[str, t.Any]: |
| 36 |
attrs = INDEX_ATTRIBUTES[index_id] |
| 37 |
return { |
| 38 |
"@datatype": "GSearchIndex", |
| 39 |
"@version": "2017-09-01", |
| 40 |
"id": index_id, |
| 41 |
"is_trial": False if attrs["subscription_id"] else True, |
| 42 |
"status": "open", |
| 43 |
**attrs, |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
RESPONSES = ResponseSet( |
| 48 |
metadata={"index_ids": INDEX_IDS, "index_attributes": INDEX_ATTRIBUTES}, |
| 49 |
default=RegisteredResponse( |
| 50 |
service="search", |
| 51 |
path="/v1/index_list", |
| 52 |
json={ |
| 53 |
"index_list": [ |
| 54 |
_make_doc(INDEX_IDS[0]), |
| 55 |
_make_doc(INDEX_IDS[1]), |
| 56 |
] |
| 57 |
}, |
| 58 |
), |
| 59 |
) |