How to use the canvasapi.Canvas 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_canvas.py View on Github external
def test_init_warns_when_url_is_http(self, m):
        with warnings.catch_warnings(record=True):
            Canvas(settings.BASE_URL_AS_HTTP, settings.API_KEY)
            self.assertRaises(
                UserWarning,
                msg=(
                    "Canvas may respond unexpectedly when making requests to HTTP"
                    "URLs. If possible, please use HTTPS."
github ucfopen / canvasapi / tests / test_outcome_import.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)

        self.outcome_import = OutcomeImport(
            self.canvas._Canvas__requester, {"id": 1, "workflow_state": 1}
        )
github ucfopen / canvasapi / tests / test_util.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
github ucfopen / canvasapi / tests / test_authentication_providers.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)

        with requests_mock.Mocker() as m:
            register_uris({
                'account': ['get_by_id', 'add_authentication_providers']
            }, m)

            self.account = self.canvas.get_account(1)
            self.authentication_providers = self.account.add_authentication_providers(
                authentication_providers={
                    "auth_type": "Authentication Providers"
                }
github ucfopen / canvasapi / tests / test_collaboration.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)

        self.collaborator = Collaborator(
            self.canvas._Canvas__requester,
            {"id": 12345, "type": "user", "name": "Don Draper"},
        )
github ucfopen / canvasapi / tests / test_group.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
        with requests_mock.Mocker() as m:
            register_uris({"course": ["get_by_id", "create_group_category"]}, m)

            self.course = self.canvas.get_course(1)
            self.group_category = self.course.create_group_category("Test String")
github ucfopen / canvasapi / tests / test_canvas.py View on Github external
def test_init_strips_extra_spaces_in_api_key(self, m):
        client = Canvas(settings.BASE_URL, " 12345 ")
        self.assertEqual(client._Canvas__requester.access_token, "12345")
github ucfopen / canvasapi / tests / test_authentication_event.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)

        with requests_mock.Mocker() as m:
            requires = {
                "account": ["get_by_id", "get_authentication_events"],
                "login": ["create_user_login", "get_authentication_events"],
                "user": ["get_by_id", "get_authentication_events"],
            }
            register_uris(requires, m)

            self.account = self.canvas.get_account(1)
            self.login = self.account.create_user_login(
                user={"id": 1}, login={"unique_id": "belieber@example.com"}
            )
            self.user = self.canvas.get_user(1)

            self.authentication_event_account = self.account.get_authentication_events()[
github ucfopen / canvasapi / tests / test_quiz.py View on Github external
def setUp(self):
        self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)

        self.submission_question = QuizSubmissionQuestion(
            self.canvas._Canvas__requester,
            {
                "id": 1,
                "flagged": None,
                "answer": None,
                "quiz_submission_id": 1,
                "validation_token": "this is a token",
                "attempt": 1,
            },
github marklalor / clanvas / clanvas / clanvas.py View on Github external
def __init__(self, url, token):
        self.url = url
        self.host = urlparse(url).netloc
        self.canvas = Canvas(url, token)

        # Cacheable
        self.__courses = None
        self.current_user_profile = None

        self.current_course = None
        self.home = os.path.expanduser("~")
        self.current_directory = self.home