def promote_team_leader(self, user): return API.update_sub_resource( self.__class__.name(), self.Id, 'leaders', user.Id )
def promote_team_admin(self, user): return API.update_sub_resource( self.__class__.name(), self.Id, 'admins', user.Id )
def test_update_sub_resource(self, request): request.return_value = Mock(status_code=200, text='[]') eq_( API.update_sub_resource('pies', None, 'chips', 'five', {'Name': 'Cheese & Onion'}), []) request.assert_called_once_with( 'PUT', 'https://api.litmos.com/v1.svc/pies/chips/five?apikey=api-key-123&source=app-name-123&format=json', json={'Name': 'Cheese & Onion'})
def module_complete(self, module_id, attributes): attributes['CourseId'] = self.Id iso_8601_date = attributes['UpdatedAt'] updated_at_datetime = datetime.datetime.strptime(iso_8601_date, '%Y-%m-%dT%H:%M:%S.%fZ') epoch_datetime = int(updated_at_datetime.timestamp() * 1000) attributes['UpdatedAt'] = "/Date({0})/".format(epoch_datetime) return API.update_sub_resource( 'results', None, 'modules', module_id, attributes )