Skip to content

Commit

Permalink
test: Expanding test in search manager (box/box-codegen#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Oct 31, 2024
1 parent c33c99a commit d01f1aa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "0a79fc3", "specHash": "90cf4e4", "version": "1.6.0" }
{ "engineHash": "4d95546", "specHash": "9d452cf", "version": "1.6.0" }
4 changes: 2 additions & 2 deletions box_sdk_gen/managers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def search_by_metadata_query(
ancestor_folder_id: str,
*,
query: Optional[str] = None,
query_params: Optional[Dict[str, str]] = None,
query_params: Optional[Dict] = None,
order_by: Optional[List[SearchByMetadataQueryOrderBy]] = None,
limit: Optional[int] = None,
marker: Optional[str] = None,
Expand Down Expand Up @@ -176,7 +176,7 @@ def search_by_metadata_query(
:param query_params: Set of arguments corresponding to the parameters specified in the
`query`. The type of each parameter used in the `query_params` must match
the type of the corresponding metadata template field., defaults to None
:type query_params: Optional[Dict[str, str]], optional
:type query_params: Optional[Dict], optional
:param order_by: A list of template fields and directions to sort the metadata query
results by.
Expand Down
4 changes: 2 additions & 2 deletions box_sdk_gen/schemas/metadata_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
ancestor_folder_id: str,
*,
query: Optional[str] = None,
query_params: Optional[Dict[str, str]] = None,
query_params: Optional[Dict] = None,
order_by: Optional[List[MetadataQueryOrderByField]] = None,
limit: Optional[int] = None,
marker: Optional[str] = None,
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(
:param query_params: Set of arguments corresponding to the parameters specified in the
`query`. The type of each parameter used in the `query_params` must match
the type of the corresponding metadata template field., defaults to None
:type query_params: Optional[Dict[str, str]], optional
:type query_params: Optional[Dict], optional
:param order_by: A list of template fields and directions to sort the metadata query
results by.
Expand Down
7 changes: 5 additions & 2 deletions docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ See the endpoint docs at

```python
client.search.search_by_metadata_query(
search_from, "0", query="testName >= :value", query_params={"value": "0.0"}
search_from,
"0",
query="testColor = :value",
query_params={"value": ["red", "blue"]},
)
```

Expand All @@ -31,7 +34,7 @@ client.search.search_by_metadata_query(
- Specifies the template used in the query. Must be in the form `scope.templateKey`. Not all templates can be used in this field, most notably the built-in, Box-provided classification templates can not be used in a query.
- query `Optional[str]`
- The query to perform. A query is a logical expression that is very similar to a SQL `SELECT` statement. Values in the search query can be turned into parameters specified in the `query_param` arguments list to prevent having to manually insert search values into the query string. For example, a value of `:amount` would represent the `amount` value in `query_params` object.
- query_params `Optional[Dict[str, str]]`
- query_params `Optional[Dict]`
- Set of arguments corresponding to the parameters specified in the `query`. The type of each parameter used in the `query_params` must match the type of the corresponding metadata template field.
- ancestor_folder_id `str`
- The ID of the folder that you are restricting the query to. A value of zero will return results from all folders you have access to. A non-zero value will only return results found in the folder corresponding to the ID or in any of its subfolders.
Expand Down
26 changes: 17 additions & 9 deletions test/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
CreateMetadataTemplateFieldsTypeField,
)

from box_sdk_gen.managers.metadata_templates import (
CreateMetadataTemplateFieldsOptionsField,
)

from box_sdk_gen.schemas.files import Files

from box_sdk_gen.managers.uploads import UploadFileAttributes
Expand All @@ -36,10 +40,6 @@

from box_sdk_gen.managers.search import SearchForContentTrashContent

from box_sdk_gen.managers.metadata_templates import (
CreateMetadataTemplateFieldsOptionsField,
)

from box_sdk_gen.schemas.metadata_filter import MetadataFilter

from box_sdk_gen.schemas.metadata_filter import MetadataFilterScopeField
Expand Down Expand Up @@ -71,9 +71,14 @@ def testCreateMetaDataQueryExecuteRead():
template_key=template_key,
fields=[
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.FLOAT.value,
key='testName',
display_name='testName',
type=CreateMetadataTemplateFieldsTypeField.MULTISELECT.value,
key='testColor',
display_name='testColor',
options=[
CreateMetadataTemplateFieldsOptionsField(key='red'),
CreateMetadataTemplateFieldsOptionsField(key='green'),
CreateMetadataTemplateFieldsOptionsField(key='blue'),
],
)
],
)
Expand All @@ -89,13 +94,16 @@ def testCreateMetaDataQueryExecuteRead():
file.id,
CreateFileMetadataByIdScope.ENTERPRISE.value,
template_key,
{'testName': 1},
{'testColor': ['red', 'blue']},
)
assert metadata.template == template_key
assert metadata.scope == template.scope
search_from: str = ''.join([template.scope, '.', template.template_key])
query: MetadataQueryResults = client.search.search_by_metadata_query(
search_from, '0', query='testName >= :value', query_params={'value': '0.0'}
search_from,
'0',
query='testColor = :value',
query_params={'value': ['red', 'blue']},
)
assert len(query.entries) >= 0
client.metadata_templates.delete_metadata_template(
Expand Down

0 comments on commit d01f1aa

Please sign in to comment.