def test_create_multiple(self, mock_3d_asset_mappings_response): res = THREE_D_API.asset_mappings.create( model_id=1, revision_id=1, asset_mapping=[ThreeDAssetMapping(node_id=1, asset_id=1)]) assert isinstance(res, ThreeDAssetMappingList) assert mock_3d_asset_mappings_response.calls[0].response.json( )["items"] == res.dump(camel_case=True)
def test_delete(self, mock_3d_asset_mappings_response): res = THREE_D_API.asset_mappings.delete( model_id=1, revision_id=1, asset_mapping=ThreeDAssetMapping(1, 1)) assert res is None assert [{ "nodeId": 1, "assetId": 1 }] == jsgz_load( mock_3d_asset_mappings_response.calls[0].request.body)["items"]
def test_delete_fails(self, rsps): rsps.add( rsps.POST, THREE_D_API._get_base_url_with_base_path() + "/3d/models/1/revisions/1/mappings/delete", status=500, json={"error": { "message": "Server Error", "code": 500 }}, ) with pytest.raises(CogniteAPIError) as e: THREE_D_API.asset_mappings.delete( model_id=1, revision_id=1, asset_mapping=[ThreeDAssetMapping(1, 1)]) assert e.value.unknown == [ ThreeDAssetMapping._load({ "assetId": 1, "nodeId": 1 }) ]