def test_create_user(self, mock_create):
        canvas = Users()

        new_user = CanvasUser(
            name="J AVG USR",
            login_id="testid99",
            sis_user_id="DEB35E0A465242CF9C5CDBC108050EC0",
            email="*****@*****.**",
            locale="en")

        account_id = 88888
        canvas.create_user(new_user, account_id)
        mock_create.assert_called_with('/api/v1/accounts/88888/users', {
            'communication_channel': {
                'type': 'email',
                'skip_confirmation': True,
                'address': '*****@*****.**'
            },
            'user': {
                'locale': 'en',
                'sortable_name': None,
                'name': 'J AVG USR',
                'short_name': None,
                'time_zone': None
            },
            'pseudonym': {
                'sis_user_id': 'DEB35E0A465242CF9C5CDBC108050EC0',
                'send_confirmation': False,
                'unique_id': 'testid99'
            }
        })
Exemplo n.º 2
0
    def get_user(self, user_id, params={}):
        """
        Returns user details.

        https://canvas.instructure.com/doc/api/users.html#method.users.api_show
        """
        url = USERS_API.format(user_id)
        return CanvasUser(data=self._get_resource(url, params=params))
Exemplo n.º 3
0
    def get_user(self, user_id):
        """
        Returns user profile data.

        https://canvas.instructure.com/doc/api/users.html#method.profile.settings
        """
        url = USERS_API.format(user_id) + "/profile"
        return CanvasUser(data=self._get_resource(url))
Exemplo n.º 4
0
    def merge_users(self, user, destination_user):
        """
        Merge user into another user.

        https://canvas.instructure.com/doc/api/users.html#method.users.merge_into
        """
        url = USERS_API.format(user.user_id) + "/merge_into/{}".format(
            destination_user.user_id)
        data = self._put_resource(url)
        return CanvasUser(data=data)
Exemplo n.º 5
0
 def get_users_for_course(self, course_id, params={}):
     """
     Returns a list of users for the given course id.
     """
     url = COURSES_API.format(course_id) + "/users"
     data = self._get_paged_resource(url, params=params)
     users = []
     for datum in data:
         users.append(CanvasUser(data=datum))
     return users
    def test_create_user(self):
        canvas = Users()

        new_user = CanvasUser(
            name="J AVG USR",
            login_id="testid99",
            sis_user_id="DEB35E0A465242CF9C5CDBC108050EC0",
            email="*****@*****.**",
            locale="en")

        self.assertRaises(MissingAccountID, canvas.create_user, new_user)
Exemplo n.º 7
0
    def test_merge_users(self, mock_merge):
        canvas = Users()

        user = CanvasUser(
            user_id=12345,
            name="J AVG USR",
            login_id="testid99",
            sis_user_id="DEB35E0A465242CF9C5CDBC108050EC0",
            email="*****@*****.**",
            locale="en")

        destination_user = CanvasUser(
            user_id=56789,
            name="J AVG USR",
            login_id="javerage",
            sis_user_id="15AE3883B6EC44C349E04E5FE089ABEB",
            email="*****@*****.**",
            locale="en")

        canvas.merge_users(user, destination_user)
        mock_merge.assert_called_with('/api/v1/users/12345/merge_into/56789')
Exemplo n.º 8
0
    def create_user(self, user, account_id=None):
        """
        Create and return a new user and pseudonym for an account.

        https://canvas.instructure.com/doc/api/users.html#method.users.create
        """
        if account_id is None:
            account_id = self._canvas_account_id
            if account_id is None:
                raise MissingAccountID()

        url = ACCOUNTS_API.format(account_id) + "/users"

        data = self._post_resource(url, user.post_data())
        return CanvasUser(data=data)
Exemplo n.º 9
0
def create_user(**kwargs):
    return Users().create_user(CanvasUser(**kwargs))
Exemplo n.º 10
0
def get_person_by_gmail_id(gmail_id):
    return CanvasUser(sis_user_id=valid_gmail_id(gmail_id),
                      login_id=gmail_id.lower(),
                      email=gmail_id)