Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

TestMockSpaceService

Mock implementation of SpaceService for testing. All methods return mock data instead of making actual API calls.

Attributes
AUTH_API_KEY_HEADER_PREFIX: strAUTH_HEADER_KEY: strUSER_ID_HEADER_KEY: str
Functions
__init__

Constructor of the SpaceService

add_or_replace_tags_on_object

Mock add_or_replace_tags_on_object - returns the same tags

entity_id : str
tags : list
Return type : list
add_tags_to_object

Mock add_tags_to_object - returns the same tags

entity_id : str
tags : list
Return type : list
check_2_fa

Mock check_2_fa - returns mock UserSpace

credentials : UserCredentials2Fa
Return type : UserSpace
check_api_key

Mock check_api_key - always returns True

api_key : str
Return type : bool
check_credentials

Mock check_credentials - returns mock response

credentials : UserCredentialsDTO
for_login : bool - True
create_child_folder

Mock create_child_folder

parent_id : str
folder : ExternalSpaceCreateFolder
Return type : ExternalSpaceFolder
create_constellab_document

Create a Constellab document in a folder in space

folder_id : str
id of the parent folder
name : str
name of the document
Return type : SpaceHierarchyObjectDTO
create_root_folder

Mock create_root_folder that returns a fake folder

folder : ExternalSpaceCreateFolder
Return type : ExternalSpaceFolder
delete_document

Delete a document by moving it to trash

document_id : str
id of the document to delete
Return type : SpaceHierarchyObjectDTO
delete_folder

Mock delete_folder

folder_id : str
delete_lab_note

Mock delete_note

folder_id : str
note_id : str
delete_scenario

Mock delete_scenario

folder_id : str
scenario_id : str
delete_tags_on_object

Mock delete_tags_on_object

entity_id : str
tags : list
download_document_bytes

Download a document from space and return the bytes directly

document_id : str
id of the document to download
filename : str | None
filename for URL readability (not used in logic)
Return type : bytes
get_all_current_user_root_folders

Mock get_all_current_user_root_folders - returns empty list

Return type : list
get_all_lab_root_folders

Mock get_all_lab_root_folders - returns empty folders

Return type : ExternalSpaceFolders
get_all_lab_users

Mock get_all_lab_users - returns empty list

Return type : list
get_current_lab_all_groups

Get all groups for the current lab

Return type : list
get_folder_users

Mock get_folder_users - returns empty list

folder_id : str
Return type : list
get_lab_root_folder

Mock get_lab_root_folder

id_ : str
Return type : ExternalSpaceFolder
get_reflex_access_token

Mock get_reflex_access_token - returns a fake token

Return type : str
get_rich_text_modifications

Mock get_modifications

old_content : RichTextDTO
new_content : RichTextDTO
old_modifications : gws_core.impl.rich_text.rich_text_modification.RichTextModificationsDTO | None
Return type : RichTextModificationsDTO
get_rich_text_undo_content

Mock get_undo_content

content : RichTextDTO
modifications : RichTextModificationsDTO
modification_id : str
Return type : RichTextDTO
get_synced_lab_notes

Mock get_synced_notes - returns empty list

Return type : list
get_synced_scenarios

Mock get_synced_scenarios - returns empty list

Return type : list
get_user_info

Mock get_user_info

user_id : str
Return type : UserFullDTO
handle_error

Centralized error handler for all space service operations. Converts connection errors to user-friendly messages.

error : Exception
The exception that was raised
operation_description : str
Description of the operation that failed (e.g., "create folder", "save scenario")
Return type : NoReturn
register_lab_start

Mock register_lab_start - always returns True

lab_config : LabConfigModelDTO
Return type : bool
rename_document

Rename a document in space

document_id : str
id of the document to rename
name : str
new name for the document
save_lab_note

Mock save_note

folder_id : str
note : SaveNoteToSpaceDTO
form_data : FormData
Return type : SpaceHierarchyObjectDTO
save_scenario

Mock save_scenario

folder_id : str
save_scenario_dto : SaveScenarioToSpaceDTO
Return type : SpaceHierarchyObjectDTO
search_project_children_objects_paginated

Get paginated children of a folder with search capabilities

folder_id : str
id of the folder to get children from
search_params : SpaceHierarchyObjectSearchParams
search and filter parameters
page : int
page number (0-indexed)
size : int
page size (number of items per page)
Return type : PageDTO[SpaceHierarchyObjectDTO]
send_mail

Mock send_mail

send_mail_dto : SpaceSendMailToUsersDTO
Return type : Response
send_mail_to_mails

Mock send_mail_to_mails

send_mail_to_mails_dto : SpaceSendMailToMailsDTO
Return type : Response
send_mail_to_support

Send a mail to support.

send_mail_to_support_dto : SpaceSendMailToSupportDTO
mail information
Return type : Response
send_notification

Mock send_notification

send_notification_dto : SpaceSendNotificationDTO
Return type : Response
set_space_folder_users_mock

Set mock space folder users

users : list
share_resource

Mock share_resource

folder_id : str
resource_dto : ShareResourceWithSpaceDTO
Return type : SpaceHierarchyObjectDTO
share_root_folder

Mock share_root_folder

root_folder_id : str
group_id : str
role : SpaceRootFolderUserRole - SpaceRootFolderUserRole.USER
Return type : list
share_root_folder_with_current_lab

Mock share_root_folder_with_current_lab

root_folder_id : str
Return type : ExternalSpaceFolder
unshare_root_folder

Mock unshare_folder

folder_id : str
group_id : str
update_folder

Mock update_folder that returns a fake updated folder

folder_id : str
folder : ExternalSpaceCreateFolder
Return type : ExternalSpaceFolder
update_folder_user_role

Update the role of a user for a folder. This is an alias for update_share_folder.

folder_id : str
id of the folder
user_id : str
id of the user
role : SpaceRootFolderUserRole
new role for the user
update_lab_note_folder

Mock update_note_folder

current_folder_id : str
note_id : str
new_folder_id : str
update_scenario_folder

Mock update_scenario_folder

current_folder_id : str
scenario_id : str
new_folder_id : str
update_share_folder

Mock update_share_folder

folder_id : str
user_id : str
role : SpaceRootFolderUserRole
upload_document

Upload a document to a folder in space

parent_folder_id : str
id of the parent folder
file_path : str
path to the file to upload
override_mode : DocumentUploadOverrideMode
how to handle existing files with the same name (IGNORE, ERROR, REPLACE, RENAME)
filename : str | None
custom filename
Return type : SpaceHierarchyObjectDTO
create_with_access_token @classmethod

Return a new instance of the SpaceService that use the access token for authentication

Return type : SpaceServiceBaseType
get_instance @classmethod

Return a new instance of the SpaceService that use the current user for authentication

Return type : SpaceServiceBaseType
get_user_profile_picture_url @classmethod

Generate URL for user profile picture with specified size.

photo : str
Base URL of the user's photo
Return type : str
build_page_dto_from_space_json @staticmethod

Build a PageDTO from Space API JSON response format (ClPageI).

The Space API returns paginated data in the ClPageI format: { "objects": T[], "first": boolean, "last": boolean, "totalElements": number, "currentPage": number, "pageSize": number, "totalIsApproximate"?: boolean }

This method converts it to the internal PageDTO format.

json_data : dict
The JSON response from the Space API
object_converter : Callable
Function to convert each object in the list from JSON to the target DTO type
Return type : PageDTO[~T]
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.