Skip to content

Commit cc9c7bb

Browse files
committed
#788: fix batch request issue
1 parent 2d6d934 commit cc9c7bb

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed

Diff for: examples/sharepoint/listitems/create_batch.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
from office365.sharepoint.client_context import ClientContext
66
from tests import create_unique_name, test_client_credentials, test_team_site_url
77

8+
9+
def print_progress(items_count):
10+
print("{0} list items has been created".format(items_count))
11+
12+
813
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
914
tasks_list = ctx.web.lists.get_by_title("Company Tasks")
1015

11-
num_of_items = 10
16+
num_of_items = 1024
1217
item_props = {"Title": create_unique_name("Task")}
1318
task_items = [tasks_list.add_item(item_props) for idx in range(0, num_of_items)]
14-
ctx.execute_batch()
19+
ctx.execute_batch(success_callback=print_progress)
1520
print("{0} task items created".format(len(task_items)))

Diff for: examples/sharepoint/taxonomy/get_term_store_info.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from office365.sharepoint.client_context import ClientContext
2+
from tests import test_client_credentials, test_team_site_url
3+
4+
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
5+
term_store = ctx.taxonomy.term_store.get().execute_query()
6+
print(term_store)

Diff for: office365/runtime/odata/query_options.py

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def build(client_object, properties_to_include=None):
5959
ClientObjectCollection,
6060
)
6161

62+
if name in query_options.select:
63+
continue
64+
6265
if isinstance(client_object, ClientObjectCollection):
6366
prop = client_object.create_typed_object().get_property(name)
6467
else:

Diff for: office365/sharepoint/client_context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def execute_batch(self, items_per_batch=100, success_callback=None):
201201
"""
202202
Construct and submit to a server a batch request
203203
:param int items_per_batch: Maximum to be selected for bulk operation
204-
:param (int)-> None success_callback: A callback
204+
:param (int)-> None success_callback: A success callback
205205
"""
206206
batch_request = ODataBatchV3Request(JsonLightFormat())
207207
batch_request.beforeExecute += self._authenticate_request

Diff for: office365/sharepoint/tenant/administration/tenant.py

+30-6
Original file line numberDiff line numberDiff line change
@@ -330,22 +330,46 @@ def get_ransomware_activities(self):
330330
self.context.add_query(qry)
331331
return return_type
332332

333-
def get_sp_list_item_count(self, listName):
333+
def get_sp_list_item_count(self, list_name):
334334
# type: (str) -> ClientResult[int]
335335
""" """
336336
return_type = ClientResult(self.context)
337-
payload = {"listName": listName}
337+
payload = {"listName": list_name}
338338
qry = ServiceOperationQuery(
339339
self, "GetSPListItemCount", None, payload, None, return_type
340340
)
341341
self.context.add_query(qry)
342342
return return_type
343343

344+
def get_sp_list_root_folder_properties(self, list_name):
345+
# type: (str) -> ClientResult[dict]
346+
""" """
347+
return_type = ClientResult(self.context)
348+
payload = {"listName": list_name}
349+
qry = ServiceOperationQuery(
350+
self, "GetSPListRootFolderProperties", None, payload, None, return_type
351+
)
352+
self.context.add_query(qry)
353+
return return_type
354+
355+
def get_spo_all_web_templates(self, culture_name=None, compatibility_level=None):
356+
# type: (str, int) -> SPOTenantWebTemplateCollection
357+
""" """
358+
return_type = SPOTenantWebTemplateCollection(self.context)
359+
payload = {
360+
"cultureName": culture_name,
361+
"compatibilityLevel": compatibility_level,
362+
}
363+
qry = ServiceOperationQuery(
364+
self, "GetSPOAllWebTemplates", None, payload, None, return_type
365+
)
366+
self.context.add_query(qry)
367+
return return_type
368+
344369
def check_tenant_intune_license(self):
345-
"""
346-
Checks whether a tenant has the Intune license.
347-
"""
348-
return_type = ClientResult(self.context) # type: ClientResult[bool]
370+
# type: () -> ClientResult[bool]
371+
"""Checks whether a tenant has the Intune license."""
372+
return_type = ClientResult(self.context)
349373
qry = ServiceOperationQuery(
350374
self, "CheckTenantIntuneLicense", None, None, None, return_type
351375
)

Diff for: tests/sharepoint/test_tenant.py

+4
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ def test_25_get_power_apps_environments(self):
188188
# def test_26_get_ransomware_activities(self):
189189
# result = self.tenant.get_ransomware_activities().execute_query()
190190
# self.assertIsNotNone(result.value)
191+
192+
def test_27_get_get_spo_all_web_templates(self):
193+
result = self.tenant.get_spo_all_web_templates().execute_query()
194+
self.assertIsNotNone(result)

0 commit comments

Comments
 (0)