diff --git a/.codegen.json b/.codegen.json index 1d79711b..53f51ce9 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "576c827", "specHash": "1e0848d", "version": "4.2.0" } +{ "engineHash": "c370934", "specHash": "1e0848d", "version": "4.2.0" } diff --git a/docs/box_sdk_gen/metadata_taxonomies.md b/docs/box_sdk_gen/metadata_taxonomies.md index 9c03b697..062980df 100644 --- a/docs/box_sdk_gen/metadata_taxonomies.md +++ b/docs/box_sdk_gen/metadata_taxonomies.md @@ -26,7 +26,11 @@ This operation is performed by calling function `create_metadata_taxonomy`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-metadata-taxonomies/). -_Currently we don't have an example for calling `create_metadata_taxonomy` in integration tests_ + + +```python +client.metadata_taxonomies.create_metadata_taxonomy(display_name, namespace, key=taxonomy_key) +``` ### Arguments @@ -54,7 +58,11 @@ This operation is performed by calling function `get_metadata_taxonomies`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id/). -_Currently we don't have an example for calling `get_metadata_taxonomies` in integration tests_ + + +```python +client.metadata_taxonomies.get_metadata_taxonomies(namespace) +``` ### Arguments @@ -83,7 +91,11 @@ This operation is performed by calling function `get_metadata_taxonomy_by_key`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id/). -_Currently we don't have an example for calling `get_metadata_taxonomy_by_key` in integration tests_ + + +```python +client.metadata_taxonomies.get_metadata_taxonomy_by_key(namespace, taxonomy_key) +``` ### Arguments @@ -109,7 +121,11 @@ This operation is performed by calling function `update_metadata_taxonomy`. See the endpoint docs at [API Reference](https://developer.box.com/reference/patch-metadata-taxonomies-id-id/). -_Currently we don't have an example for calling `update_metadata_taxonomy` in integration tests_ + + +```python +client.metadata_taxonomies.update_metadata_taxonomy(namespace, taxonomy_key, updated_display_name) +``` ### Arguments @@ -138,7 +154,11 @@ This operation is performed by calling function `delete_metadata_taxonomy`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-metadata-taxonomies-id-id/). -_Currently we don't have an example for calling `delete_metadata_taxonomy` in integration tests_ + + +```python +client.metadata_taxonomies.delete_metadata_taxonomy(namespace, taxonomy_key) +``` ### Arguments @@ -164,7 +184,11 @@ This operation is performed by calling function `create_metadata_taxonomy_level` See the endpoint docs at [API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels/). -_Currently we don't have an example for calling `create_metadata_taxonomy_level` in integration tests_ + + +```python +client.metadata_taxonomies.create_metadata_taxonomy_level(namespace, taxonomy_key, [MetadataTaxonomyLevel(display_name='Continent', description='Continent Level'), MetadataTaxonomyLevel(display_name='Country', description='Country Level')]) +``` ### Arguments @@ -225,7 +249,11 @@ This operation is performed by calling function `add_metadata_taxonomy_level`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels:append/). -_Currently we don't have an example for calling `add_metadata_taxonomy_level` in integration tests_ + + +```python +client.metadata_taxonomies.add_metadata_taxonomy_level(namespace, taxonomy_key, 'Region', description='Region Description') +``` ### Arguments @@ -255,7 +283,11 @@ This operation is performed by calling function `delete_metadata_taxonomy_level` See the endpoint docs at [API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels:trim/). -_Currently we don't have an example for calling `delete_metadata_taxonomy_level` in integration tests_ + + +```python +client.metadata_taxonomies.delete_metadata_taxonomy_level(namespace, taxonomy_key) +``` ### Arguments @@ -283,7 +315,11 @@ This operation is performed by calling function `get_metadata_taxonomy_nodes`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id-nodes/). -_Currently we don't have an example for calling `get_metadata_taxonomy_nodes` in integration tests_ + + +```python +client.metadata_taxonomies.get_metadata_taxonomy_nodes(namespace, taxonomy_key) +``` ### Arguments @@ -323,7 +359,11 @@ This operation is performed by calling function `create_metadata_taxonomy_node`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-nodes/). -_Currently we don't have an example for calling `create_metadata_taxonomy_node` in integration tests_ + + +```python +client.metadata_taxonomies.create_metadata_taxonomy_node(namespace, taxonomy_key, 'Europe', 1) +``` ### Arguments @@ -355,7 +395,11 @@ This operation is performed by calling function `get_metadata_taxonomy_node_by_i See the endpoint docs at [API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id-nodes-id/). -_Currently we don't have an example for calling `get_metadata_taxonomy_node_by_id` in integration tests_ + + +```python +client.metadata_taxonomies.get_metadata_taxonomy_node_by_id(namespace, taxonomy_key, country_node.id) +``` ### Arguments @@ -383,7 +427,11 @@ This operation is performed by calling function `update_metadata_taxonomy_node`. See the endpoint docs at [API Reference](https://developer.box.com/reference/patch-metadata-taxonomies-id-id-nodes-id/). -_Currently we don't have an example for calling `update_metadata_taxonomy_node` in integration tests_ + + +```python +client.metadata_taxonomies.update_metadata_taxonomy_node(namespace, taxonomy_key, country_node.id, display_name='Poland UPDATED') +``` ### Arguments @@ -415,7 +463,11 @@ This operation is performed by calling function `delete_metadata_taxonomy_node`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-metadata-taxonomies-id-id-nodes-id/). -_Currently we don't have an example for calling `delete_metadata_taxonomy_node` in integration tests_ + + +```python +client.metadata_taxonomies.delete_metadata_taxonomy_node(namespace, taxonomy_key, country_node.id) +``` ### Arguments diff --git a/test/box_sdk_gen/test/metadata_taxonomies.py b/test/box_sdk_gen/test/metadata_taxonomies.py new file mode 100644 index 00000000..23f2675d --- /dev/null +++ b/test/box_sdk_gen/test/metadata_taxonomies.py @@ -0,0 +1,156 @@ +import pytest + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas.metadata_taxonomy import MetadataTaxonomy + +from box_sdk_gen.schemas.metadata_taxonomies import MetadataTaxonomies + +from box_sdk_gen.schemas.metadata_taxonomy_levels import MetadataTaxonomyLevels + +from box_sdk_gen.schemas.metadata_taxonomy_level import MetadataTaxonomyLevel + +from box_sdk_gen.schemas.metadata_taxonomy_node import MetadataTaxonomyNode + +from box_sdk_gen.schemas.metadata_taxonomy_nodes import MetadataTaxonomyNodes + +from box_sdk_gen.internal.utils import get_uuid + +from box_sdk_gen.internal.utils import get_env_var + +from box_sdk_gen.internal.utils import delay_in_seconds + +from test.box_sdk_gen.test.commons import get_default_client + +client: BoxClient = get_default_client() + + +def testMetadataTaxonomiesCRUD(): + namespace: str = ''.join(['enterprise_', get_env_var('ENTERPRISE_ID')]) + uuid: str = get_uuid() + taxonomy_key: str = ''.join(['geography', uuid]) + display_name: str = ''.join(['Geography Taxonomy', uuid]) + created_taxonomy: MetadataTaxonomy = ( + client.metadata_taxonomies.create_metadata_taxonomy( + display_name, namespace, key=taxonomy_key + ) + ) + assert created_taxonomy.display_name == display_name + assert created_taxonomy.namespace == namespace + taxonomies: MetadataTaxonomies = client.metadata_taxonomies.get_metadata_taxonomies( + namespace + ) + assert len(taxonomies.entries) > 0 + assert taxonomies.entries[0].namespace == namespace + updated_display_name: str = ''.join(['Geography Taxonomy UPDATED', uuid]) + updated_taxonomy: MetadataTaxonomy = ( + client.metadata_taxonomies.update_metadata_taxonomy( + namespace, taxonomy_key, updated_display_name + ) + ) + assert updated_taxonomy.display_name == updated_display_name + assert updated_taxonomy.namespace == namespace + assert updated_taxonomy.id == created_taxonomy.id + get_taxonomy: MetadataTaxonomy = ( + client.metadata_taxonomies.get_metadata_taxonomy_by_key(namespace, taxonomy_key) + ) + assert get_taxonomy.display_name == updated_display_name + assert get_taxonomy.namespace == namespace + assert get_taxonomy.id == created_taxonomy.id + client.metadata_taxonomies.delete_metadata_taxonomy(namespace, taxonomy_key) + with pytest.raises(Exception): + client.metadata_taxonomies.get_metadata_taxonomy_by_key(namespace, taxonomy_key) + + +def testMetadataTaxonomiesNodes(): + namespace: str = ''.join(['enterprise_', get_env_var('ENTERPRISE_ID')]) + uuid: str = get_uuid() + taxonomy_key: str = ''.join(['geography', uuid]) + display_name: str = ''.join(['Geography Taxonomy', uuid]) + created_taxonomy: MetadataTaxonomy = ( + client.metadata_taxonomies.create_metadata_taxonomy( + display_name, namespace, key=taxonomy_key + ) + ) + assert created_taxonomy.display_name == display_name + assert created_taxonomy.namespace == namespace + taxonomy_levels: MetadataTaxonomyLevels = ( + client.metadata_taxonomies.create_metadata_taxonomy_level( + namespace, + taxonomy_key, + [ + MetadataTaxonomyLevel( + display_name='Continent', description='Continent Level' + ), + MetadataTaxonomyLevel( + display_name='Country', description='Country Level' + ), + ], + ) + ) + assert len(taxonomy_levels.entries) == 2 + assert taxonomy_levels.entries[0].display_name == 'Continent' + assert taxonomy_levels.entries[1].display_name == 'Country' + taxonomy_levels_after_addition: MetadataTaxonomyLevels = ( + client.metadata_taxonomies.add_metadata_taxonomy_level( + namespace, taxonomy_key, 'Region', description='Region Description' + ) + ) + assert len(taxonomy_levels_after_addition.entries) == 3 + assert taxonomy_levels_after_addition.entries[2].display_name == 'Region' + taxonomy_levels_after_deletion: MetadataTaxonomyLevels = ( + client.metadata_taxonomies.delete_metadata_taxonomy_level( + namespace, taxonomy_key + ) + ) + assert len(taxonomy_levels_after_deletion.entries) == 2 + assert taxonomy_levels_after_deletion.entries[0].display_name == 'Continent' + assert taxonomy_levels_after_deletion.entries[1].display_name == 'Country' + continent_node: MetadataTaxonomyNode = ( + client.metadata_taxonomies.create_metadata_taxonomy_node( + namespace, taxonomy_key, 'Europe', 1 + ) + ) + assert continent_node.display_name == 'Europe' + assert continent_node.level == 1 + country_node: MetadataTaxonomyNode = ( + client.metadata_taxonomies.create_metadata_taxonomy_node( + namespace, taxonomy_key, 'Poland', 2, parent_id=continent_node.id + ) + ) + assert country_node.display_name == 'Poland' + assert country_node.level == 2 + assert country_node.parent_id == continent_node.id + delay_in_seconds(5) + all_nodes: MetadataTaxonomyNodes = ( + client.metadata_taxonomies.get_metadata_taxonomy_nodes(namespace, taxonomy_key) + ) + assert len(all_nodes.entries) == 2 + updated_country_node: MetadataTaxonomyNode = ( + client.metadata_taxonomies.update_metadata_taxonomy_node( + namespace, taxonomy_key, country_node.id, display_name='Poland UPDATED' + ) + ) + assert updated_country_node.display_name == 'Poland UPDATED' + assert updated_country_node.level == 2 + assert updated_country_node.parent_id == country_node.parent_id + assert updated_country_node.id == country_node.id + get_country_node: MetadataTaxonomyNode = ( + client.metadata_taxonomies.get_metadata_taxonomy_node_by_id( + namespace, taxonomy_key, country_node.id + ) + ) + assert get_country_node.display_name == 'Poland UPDATED' + assert get_country_node.id == country_node.id + client.metadata_taxonomies.delete_metadata_taxonomy_node( + namespace, taxonomy_key, country_node.id + ) + client.metadata_taxonomies.delete_metadata_taxonomy_node( + namespace, taxonomy_key, continent_node.id + ) + delay_in_seconds(5) + all_nodes_after_deletion: MetadataTaxonomyNodes = ( + client.metadata_taxonomies.get_metadata_taxonomy_nodes(namespace, taxonomy_key) + ) + assert len(all_nodes_after_deletion.entries) == 0 + client.metadata_taxonomies.delete_metadata_taxonomy(namespace, taxonomy_key)