MCPcopy Index your code
hub / github.com/O365/python-o365 / test_update

Method test_update

tests/test_planner.py:130–188  ·  view source on GitHub ↗
(self, object)

Source from the content-addressed store, hash-verified

128 "taskDetail",
129 ])
130 def test_update(self, object):
131 kwargs = {
132 #Update Plan
133 "plan_title" : "plan_update_" + ''.join(choices(printable, k=randint(10, 20))),
134
135 #Update Plan Detail
136 "planDetail_shared_with" : {Config.USER_ID : randint(0,1) == 1},
137 "planDetail_category_descriptions" : {
138 f"category{i}" : "category_" + ''.join(choices(printable, k=randint(10, 20)))
139 for i in range(1, 25) if randint(0,1)
140 },
141
142 #Update Bucket
143 "bucket_name" : "bucket_update_" + ''.join(choices(printable, k=randint(10, 20))),
144 #messing with order_hint will raise error
145 "bucket_order_hint" : " !",
146
147 #Update Task
148 "task_title" : "task_update_" + ''.join(choices(printable, k=randint(10, 20))),
149 "task_assignments" : {Config.USER_ID : None}, #user id : None -> remove task from that user
150 "task_priority" : choices([1, 3, 5, 9], k=1)[0],
151 "task_order_hint" : " !",
152 #if due_date_time is < start_date_time an error will be raised for inconsistency, return 400 client error
153 "task_start_date_time" : datetime.now(),
154 "task_due_date_time": datetime.now() + timedelta(days=randint(1, 30)), #30 is an arbitrary choice
155 "task_assignee_priority" : " !",
156 "task_percent_complete" : randint(0, 100),
157 "task_applied_categories" : {f"category{i}" : randint(0,1) == 1 for i in range(1, 25) if randint(0,1)},
158
159 #Update Task Detail
160 "taskDetail_checklist" : {f"{i}" : {
161 "isChecked": randint(0,1) == 1,
162 "orderHint": " !",
163 "title": "checklist_" + ''.join(choices(printable, k=randint(10, 20)))
164 } for i in range(randint(1, 10))},
165 "taskDetail_description" : "description " + ''.join(choices(printable, k=randint(10, 20))),
166 "taskDetail_preview_type" : choices(["automatic", "noPreview", "checklist", "description", "reference"], k=1)[0],
167 "taskDetail_references" : {
168 #a not correctly structured url will raise error (e.g. url without .com or others)
169 f"https://{''.join(choices(ascii_lowercase + digits, k=randint(5, 10)))}.com" : {
170 "alias": "alias " + ''.join(choices(printable, k=randint(10, 20))),
171 "previewPriority": " !",
172 "type": choices(["PowerPoint", "Excel", "Word", "Pdf"], k=1)[0],
173 } for _ in range(randint(1,10))
174 },
175 }
176
177 update_kwargs = {}
178 for key, value in kwargs.items():
179 if f"{object}_" in key :
180 update_kwargs[key[len(f"{object}_"):]] = value
181
182 if update_kwargs:
183
184 previous_etag = reduce(getattr, [self, object, "_etag"])
185 assert getattr(self, object).update(**update_kwargs)
186
187 subsequent_etag = reduce(getattr, [self, object, "_etag"])

Callers

nothing calls this directly

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected