Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_is_multivalued_set_iter(self, m):
self.assertTrue(is_multivalued(iter({"element"})))
def test_is_multivalued_dict_items(self, m):
self.assertTrue(is_multivalued(iteritems({"key": "value"})))
def test_is_multivalued_generator_call(self, m):
def yielder():
yield "item"
self.assertTrue(is_multivalued(yielder()))
def test_is_multivalued_tuple(self, m):
self.assertTrue(is_multivalued(("item",)))
def test_is_multivalued_list(self, m):
self.assertTrue(is_multivalued(["item"]))
def test_is_multivalued_generator_expr(self, m):
self.assertTrue(is_multivalued(item for item in ("item",)))
def test_is_multivalued_bool(self, m):
self.assertFalse(is_multivalued(False))
def test_is_multivalued_dict_iter(self, m):
self.assertTrue(is_multivalued(iter({"key": "value"})))
def test_is_multivalued_chain(self, m):
self.assertTrue(is_multivalued(chain((1,), (2,))))
"""
Puts the pinned discussion topics in the specified order.
All pinned topics should be included.
:calls: `POST /api/v1/courses/:course_id/discussion_topics/reorder \
`_
:param order: The ids of the pinned discussion topics in the desired order.
e.g. [104, 102, 103], (104, 102, 103), or "104,102,103"
:type order: string or iterable sequence of values
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.discussion_topic.DiscussionTopic`
"""
# Convert iterable sequence to comma-separated string
if is_multivalued(order):
order = ",".join([text_type(topic_id) for topic_id in order])
# Check if is a string with commas
if not isinstance(order, text_type) or "," not in order:
raise ValueError("Param `order` must be a list, tuple, or string.")
response = self._requester.request(
"POST", "courses/{}/discussion_topics/reorder".format(self.id), order=order
)
return response.json().get("reorder")