-
Notifications
You must be signed in to change notification settings - Fork 169
/
test_collaboration.py
65 lines (52 loc) · 2.15 KB
/
test_collaboration.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
from __future__ import absolute_import, division, print_function, unicode_literals
import unittest
import requests_mock
from canvasapi import Canvas
from canvasapi.collaboration import Collaboration, Collaborator
from canvasapi.paginated_list import PaginatedList
from tests import settings
from tests.util import register_uris
@requests_mock.Mocker()
class TestCollaboration(unittest.TestCase):
def setUp(self):
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
self.collaboration = Collaboration(
self.canvas._Canvas__requester,
{
"id": 1,
"collaboration_type": "Microsoft Office",
"document_id": "oinwoenfe8w8ef_onweufe89fef",
"user_id": 92,
"context_id": 77,
"context_type": "Course",
"url": "null",
"created_at": "2012-06-01T00:00:00-06:00",
"updated_at": "2012-06-01T00:00:00-06:00",
"description": "null",
"title": "null",
"type": "ExternalToolCollaboration",
"update_url": "null",
"user_name": "John Danger",
},
)
def test_str(self, m):
test_str = str(self.collaboration)
self.assertIsInstance(test_str, str)
def test_get_collaborators(self, m):
register_uris({"collaboration": ["get_collaborators"]}, m)
collaborator_list = self.collaboration.get_collaborators()
self.assertIsInstance(collaborator_list, PaginatedList)
self.assertIsInstance(collaborator_list[0], Collaborator)
self.assertEqual(collaborator_list[0].id, 12345)
self.assertEqual(collaborator_list[0].name, "Don Draper")
@requests_mock.Mocker()
class TestCollaborator(unittest.TestCase):
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 test_str(self, m):
test_str = str(self.collaborator)
self.assertIsInstance(test_str, str)