diff --git a/source/ftrack_api/entity/factory.py b/source/ftrack_api/entity/factory.py index 195ebd5d..67a07997 100644 --- a/source/ftrack_api/entity/factory.py +++ b/source/ftrack_api/entity/factory.py @@ -63,6 +63,9 @@ def create(self, schema, bases=None): data_type = fragment.get("type", ftrack_api.symbol.NOT_SET) + if fragment.get("restricted_projection", False): + continue + if data_type is not ftrack_api.symbol.NOT_SET: if data_type in ( "string", diff --git a/test/unit/conftest.py b/test/unit/conftest.py index cb3cdecf..50c69fe1 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -531,6 +531,19 @@ def mocked_schemas(): "required": ["id"], "default_projections": ["id"], }, + { + "id": "RestrictedProjection", + "type": "object", + "properties": { + "id": {"type": "string"}, + "restricted": {"type": "string", "restricted_projection": True}, + "normal": {"type": "string", "restricted_projection": False}, + }, + "immutable": ["id"], + "primary_key": ["id"], + "required": ["id"], + "default_projections": ["id"], + }, ] diff --git a/test/unit/test_session.py b/test/unit/test_session.py index 8735aab9..c587e220 100644 --- a/test/unit/test_session.py +++ b/test/unit/test_session.py @@ -1002,7 +1002,7 @@ def test_correct_file_type_on_sequence_component(session): def test_read_schemas_from_cache(session, temporary_valid_schema_cache): """Read valid content from schema cache.""" - expected_hash = "a98d0627b5e33966e43e1cb89b082db7" + expected_hash = "c8f8bdc59c415a5a96339647e45b751b" schemas, hash_ = session._read_schemas_from_cache(temporary_valid_schema_cache) @@ -1019,7 +1019,7 @@ def test_fail_to_read_schemas_from_invalid_cache( def test_write_schemas_to_cache(session, temporary_valid_schema_cache): """Write valid content to schema cache.""" - expected_hash = "a98d0627b5e33966e43e1cb89b082db7" + expected_hash = "c8f8bdc59c415a5a96339647e45b751b" schemas, _ = session._read_schemas_from_cache(temporary_valid_schema_cache) session._write_schemas_to_cache(schemas, temporary_valid_schema_cache) @@ -1488,3 +1488,13 @@ def test_custom_headers_session(): "abc" in new_session._request.headers.keys(), new_session._request.headers["abc"] == "def", ) + + +def test_restricted_projections(mocked_schema_session): + """Ensure properties marked with restricted_projection are not added as properties""" + entity = mocked_schema_session.create( + "RestrictedProjection", {"id": str(uuid.uuid4())} + ) + + # Ensure the restricted property is not present + assert {"id", "normal"} == set([prop.name for prop in entity.attributes])