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_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."
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}
)
def setUp(self):
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
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"
}
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"},
)
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")
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")
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()[
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,
},
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