forked from ucfopen/canvasapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rubric.py
155 lines (116 loc) · 4.96 KB
/
test_rubric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import unittest
import requests_mock
from canvasapi import Canvas
from canvasapi.rubric import Rubric, RubricAssessment, RubricAssociation
from tests import settings
from tests.util import register_uris
@requests_mock.Mocker()
class TestRubric(unittest.TestCase):
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_rubric"]}, m)
self.course = self.canvas.get_course(1)
self.rubric = self.course.create_rubric()["rubric"]
# delete
def test_delete(self, m):
register_uris({"rubric": ["delete_rubric"]}, m)
rubric = self.rubric.delete()
self.assertIsInstance(rubric, Rubric)
self.assertEqual(rubric.id, 1)
self.assertEqual(rubric.title, "Course Rubric 1")
self.assertEqual(rubric.context_id, 1)
self.assertEqual(rubric.context_type, "Course")
self.assertEqual(rubric.points_possible, 10.0)
self.assertFalse(rubric.reusable)
self.assertTrue(rubric.read_only)
self.assertTrue(rubric.free_form_critereon_comments)
self.assertTrue(rubric.hide_score_total)
# __str__()
def test__str__(self, m):
string = str(self.rubric)
self.assertIsInstance(string, str)
@requests_mock.Mocker()
class TestGradingStandard(unittest.TestCase):
def setUp(self):
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
with requests_mock.Mocker() as m:
register_uris({"course": ["get_by_id", "get_rubric_single"]}, m)
self.course = self.canvas.get_course(1)
self.rubric = self.course.get_rubric(1)
# __str__()
def test__str__(self, m):
string = str(self.rubric)
self.assertIsInstance(string, str)
@requests_mock.Mocker()
class TestRubricAssessment(unittest.TestCase):
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_rubric_with_association",
"create_rubric_association",
],
"rubric": ["create_rubric_assessment"],
},
m,
)
self.course = self.canvas.get_course(1)
self.rubric = self.course.create_rubric()
self.association = self.course.create_rubric_association()
self.assessment = self.association.create_rubric_assessment()
def test__str__(self, m):
string = str(self.assessment)
self.assertIsInstance(string, str)
def test_update(self, m):
register_uris({"rubric": ["update_rubric_assessment"]}, m)
self.assertEqual(self.assessment.provisional, "false")
updated_assessment = self.assessment.update(provisional=True)
self.assertEqual(updated_assessment.id, 1)
self.assertEqual(updated_assessment.provisional, "true")
def test_delete(self, m):
register_uris({"rubric": ["delete_rubric_assessment"]}, m)
deleted_assessment = self.assessment.delete()
self.assertEqual(deleted_assessment.id, 1)
self.assertIsInstance(deleted_assessment, RubricAssessment)
@requests_mock.Mocker()
class TestRubricAssociation(unittest.TestCase):
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_rubric_with_association",
"create_rubric_association",
]
},
m,
)
self.course = self.canvas.get_course(1)
self.rubric = self.course.create_rubric()
self.association = self.course.create_rubric_association()
# __str__()
def test__str__(self, m):
string = str(self.rubric["rubric_association"])
self.assertIsInstance(string, str)
# update
def test_update(self, m):
register_uris({"rubric": ["update_rubric_association"]}, m)
self.assertEqual(self.association.id, 4)
rubric_association = self.association.update()
self.assertEqual(rubric_association, self.association)
self.assertEqual(rubric_association.id, 5)
self.assertIsInstance(rubric_association, RubricAssociation)
self.assertEqual(rubric_association.association_type, "Assignment")
# delete
def test_delete(self, m):
register_uris({"rubric": ["delete_rubric_association"]}, m)
rubric_association = self.association.delete()
self.assertIsInstance(rubric_association, RubricAssociation)
self.assertEqual(rubric_association.id, 4)
self.assertEqual(rubric_association.association_type, "Assignment")