forked from vgrem/Office365-REST-Python-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
31 lines (26 loc) · 1.11 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from office365.sharepoint.fields.creation_information import FieldCreationInformation
from office365.sharepoint.fields.type import FieldType
from office365.sharepoint.lists.creation_information import ListCreationInformation
from office365.sharepoint.lists.template_type import ListTemplateType
from tests import create_unique_name
def upload_sample_file(context, path):
"""
:type context: office365.sharepoint.client_context.ClientContext
:type path: str
"""
folder = context.web.default_document_library().root_folder
with open(path, "rb") as f:
file = folder.files.upload(f).execute_query()
return file
def create_sample_tasks_list(web):
"""
:type web: office365.sharepoint.webs.web.Web
"""
list_title = create_unique_name("Tasks N")
list_create_info = ListCreationInformation(
list_title, None, ListTemplateType.TasksWithTimelineAndHierarchy
)
return_type = web.lists.add(list_create_info).execute_query()
field_info = FieldCreationInformation("Manager", FieldType.User)
return_type.fields.add(field_info).execute_query()
return return_type