def test_get_user(self):
        canvas = Users()

        user = canvas.get_user(188885)

        self.assertEquals(user.user_id, 188885, "Has correct user id")
        self.assertEquals(user.name, "J AVG USR", "Has correct name")
        self.assertEquals(user.short_name, None, "Has correct short name")
        self.assertEquals(
            user.sis_user_id, "DEB35E0A465242CF9C5CDBC108050EC0",
            "Has correct sis id")
        self.assertEquals(user.email, "*****@*****.**", "Has correct email")

        user = canvas.get_user_by_sis_id("DEB35E0A465242CF9C5CDBC108050EC0")

        self.assertEquals(user.user_id, 188885, "Has correct user id")
        self.assertEquals(user.name, "J AVG USR", "Has correct name")
        self.assertEquals(user.short_name, None, "Has correct short name")
        self.assertEquals(
            user.sis_user_id, "DEB35E0A465242CF9C5CDBC108050EC0",
            "Has correct sis id")
        self.assertEquals(user.email, "*****@*****.**", "Has correct email")
        self.assertEquals(user.avatar_url, (
            "https://en.gravatar.com/avatar/d8cb8c8cd40ddf0c"
            "d05241443a591868?s=80&r=g"), "Has correct avatar url")
Esempio n. 2
0
    def test_get_user_params(self, mock_get):
        canvas = Users()
        params = {'include': 'last_login'}

        user = canvas.get_user(188885, params)
        mock_get.assert_called_with('/api/v1/users/188885',
                                    params={'include': 'last_login'})

        user = canvas.get_user_by_sis_id(
            "DEB35E0A465242CF9C5CDBC108050EC0", params)
        mock_get.assert_called_with(
            '/api/v1/users/sis_user_id%3ADEB35E0A465242CF9C5CDBC108050EC0',
            params={'include': 'last_login'})
Esempio n. 3
0
    def test_json_data(self):
        canvas = Users()
        user = canvas.get_user(188885)

        self.assertEqual(user.json_data(), {
            'avatar_url': (
                'https://en.gravatar.com/avatar/d8cb8c8cd40ddf0c'
                'd05241443a591868?s=80&r=g'),
            'bio': None,
            'email': '*****@*****.**',
            'enrollments': [],
            'id': 188885,
            'last_login': '******',
            'locale': None,
            'login_id': 'testid99',
            'name': 'J AVG USR',
            'short_name': 'J USR',
            'sis_user_id': 'DEB35E0A465242CF9C5CDBC108050EC0',
            'sortable_name': 'USR, J AVG',
            'time_zone': None})