def get_all_terms(): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'Canvas') canvas = Terms() for term in canvas.get_all_terms(): print(term.name)
def test_update_term_overrides(self, mock_update): mock_update.return_value = None canvas = Terms() canvas.update_term_overrides("2013-spring", overrides={ "StudentEnrollment": {"start_at": "2013-01-07T08:00:00-05:00", "end_at": "2013-05-14T05:00:00-04:0"}}) mock_update.assert_called_with( '/api/v1/accounts/12345/terms/sis_term_id%3A2013-spring', { 'enrollment_term': { 'overrides': {'StudentEnrollment': { 'start_at': '2013-01-07T08:00:00-05:00', 'end_at': '2013-05-14T05:00:00-04:0'}}}})
def test_get_term_by_sis_id(self): canvas = Terms() sis_term_id = "2013-summer" term = canvas.get_term_by_sis_id(sis_term_id) self.assertEquals(term.term_id, 3845, "Has proper term id") self.assertEquals(term.name, "Summer 2013", "Has proper name") self.assertEquals(term.sis_term_id, sis_term_id, "Has proper sis id") self.assertEquals(term.workflow_state, "active") self.assertEquals(str(term.start_at), "2013-06-23 07:00:00+00:00") self.assertEquals(str(term.end_at), "2013-08-22 07:00:00+00:00")
def create_report(): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'Canvas') account_id = getattr(settings, 'RESTCLIENTS_CANVAS_ACCOUNT_ID') term = Terms().get_term_by_sis_id('2013-autumn') report_client = Reports() report = report_client.create_course_sis_export_report( account_id, term.term_id) print('Report created. Report ID: %s, progress: %s%%' % ( report.report_id, report.progress)) # Fetch the report data. This method will poll Canvas until the # report has been generated, and then download the data file data = report_client.get_report_data(report) # Do something with the data... # Delete the report report_client.delete_report(report)
def update_term_overrides(term_sis_id, override_dates): overrides = {} for role in override_dates.keys(): overrides[role] = { 'start_at': override_dates[role][0], 'end_at': override_dates[role][1] } return Terms().update_term_overrides(term_sis_id, overrides=overrides)
def get_unused_course_report_data(term_sis_id): term = Terms().get_term_by_sis_id(term_sis_id) account_id = getattr(settings, 'RESTCLIENTS_CANVAS_ACCOUNT_ID', None) reports = Reports() unused_course_report = reports.create_unused_courses_report( account_id, term_id=term.term_id) report_data = reports.get_report_data(unused_course_report) reports.delete_report(unused_course_report) return report_data
def get_term_by_sis_id(term_sis_id): return Terms().get_term_by_sis_id(term_sis_id)
def get_term_by_sis_id(self, sis_term_id): deprecation("Use uw_canvas.terms.get_term_by_sis_id") from uw_canvas.terms import Terms return Terms().get_term_by_sis_id(sis_term_id)
def test_get_all_terms(self): canvas = Terms() self.assertRaises(MissingAccountID, canvas.get_all_terms)
def test_get_all_terms(self): canvas = Terms() terms = canvas.get_all_terms() self.assertEquals(len(terms), 16)