Esempio n. 1
0
 def update_advanced_custom_fields(self, data: list):
     '''Takes a list of dictionaries in the format {'<FIELDNAME>':'<VALUE>'}.
     Advanced custom userfields may not be enabled by default'''
     return API.add_sub_resource(
         self.__class__.name(),
         self.Id,
         'usercustomfields',
         data
     )
Esempio n. 2
0
    def add_sub_team(self, sub_team):
        schema = copy(self.SCHEMA)
        for param in schema:
            attribute_value = getattr(sub_team, param)
            if attribute_value is not None:
                schema[param] = attribute_value

        sub_team = self._parse_response(
            API.add_sub_resource(self.__class__.name(), self.Id,
                                 self.__class__.name(), schema))

        return sub_team.Id
Esempio n. 3
0
    def add_users(self, users):
        user_list = []
        for user in users:
            schema = copy(self.USER_SCHEMA)
            for param in schema:
                attribute_value = getattr(user, param)
                if attribute_value is not None:
                    schema[param] = attribute_value

            user_list.append(schema)

        return API.add_sub_resource(self.__class__.name(), self.Id,
                                    User.name(), user_list)
Esempio n. 4
0
    def test_add_sub_resource(self, request):
        request.return_value = Mock(
            status_code=201,
            text='{\"Id\": \"1234rf\", \"Name\": \"Charlie\"}'
        )

        eq_(
            API.add_sub_resource('pies', 'wsGty', 'eaters', {'Id': '', 'Name': 'Charlie'}),
            {'Id': '1234rf', 'Name': 'Charlie'}
        )
        request.assert_called_once_with(
            'POST',
            'https://api.litmos.com/v1.svc/pies/wsGty/eaters?apikey=api-key-123&source=app-name-123&format=json',
            json={'Id': '', 'Name': 'Charlie'}
        )
Esempio n. 5
0
    def assign_courses(self, courses):
        course_list = []
        for course in courses:
            schema = copy(self.COURSE_SCHEMA)
            for param in schema:
                attribute_value = getattr(course, param)
                if attribute_value is not None:
                    schema[param] = attribute_value

            course_list.append(schema)

        return API.add_sub_resource(
            self.__class__.name(),
            self.Id,
            'courses',
            course_list
        )
Esempio n. 6
0
    def test_add_sub_resource_list(self, request):
        request.return_value = Mock(status_code=201, text='')

        result = API.add_sub_resource('pies', 'wsGty', 'eaters', [
            OrderedDict([('Id', 'wser4351'), ('UserName', 'paul.smith1'),
                         ('FirstName', 'Paul1'), ('LastName', 'Smith1')]),
            OrderedDict([('Id', 'wser435'), ('UserName', 'paul.smith'),
                         ('FirstName', 'Paul'), ('LastName', 'Smith')])
        ]),

        assert_true(result)

        request.assert_called_once_with(
            'POST',
            'https://api.litmos.com/v1.svc/pies/wsGty/eaters?apikey=api-key-123&source=app-name-123&format=json',
            json=[
                OrderedDict([('Id', 'wser4351'), ('UserName', 'paul.smith1'),
                             ('FirstName', 'Paul1'), ('LastName', 'Smith1')]),
                OrderedDict([('Id', 'wser435'), ('UserName', 'paul.smith'),
                             ('FirstName', 'Paul'), ('LastName', 'Smith')])
            ])