How to use the canvasapi.util.is_multivalued function in canvasapi

To help you get started, we’ve selected a few canvasapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_set_iter(self, m):
        self.assertTrue(is_multivalued(iter({"element"})))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_dict_items(self, m):
        self.assertTrue(is_multivalued(iteritems({"key": "value"})))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_generator_call(self, m):
        def yielder():
            yield "item"

        self.assertTrue(is_multivalued(yielder()))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_tuple(self, m):
        self.assertTrue(is_multivalued(("item",)))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_list(self, m):
        self.assertTrue(is_multivalued(["item"]))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_generator_expr(self, m):
        self.assertTrue(is_multivalued(item for item in ("item",)))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_bool(self, m):
        self.assertFalse(is_multivalued(False))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_dict_iter(self, m):
        self.assertTrue(is_multivalued(iter({"key": "value"})))
github ucfopen / canvasapi / tests / test_util.py View on Github external
def test_is_multivalued_chain(self, m):
        self.assertTrue(is_multivalued(chain((1,), (2,))))
github ucfopen / canvasapi / canvasapi / course.py View on Github external
"""
        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")