コード例 #1
0
ファイル: group.py プロジェクト: Tobiaqs/canvasapi
    def get_content_migration(self, content_migration, **kwargs):
        """
        Retrive a content migration by its ID

        :calls: `GET /api/v1/groups/:group_id/content_migrations/:id \
        <https://canvas.instructure.com/doc/api/content_migrations.html#method.content_migrations.show>`_

        :param content_migration: The object or ID of the content migration to retrieve.
        :type content_migration: int, str or :class:`canvasapi.content_migration.ContentMigration`

        :rtype: :class:`canvasapi.content_migration.ContentMigration`
        """
        from canvasapi.content_migration import ContentMigration

        migration_id = obj_or_id(content_migration, "content_migration", (ContentMigration,))

        response = self._requester.request(
            'GET',
            'groups/{}/content_migrations/{}'.format(self.id, migration_id),
            _kwargs=combine_kwargs(**kwargs)
        )

        response_json = response.json()
        response_json.update({'group_id': self.id})

        return ContentMigration(self._requester, response_json)
コード例 #2
0
ファイル: group.py プロジェクト: Tobiaqs/canvasapi
    def create_content_migration(self, migration_type, **kwargs):
        """
        Create a content migration.

        :calls: `POST /api/v1/groups/:group_id/content_migrations \
        <https://canvas.instructure.com/doc/api/content_migrations.html#method.content_migrations.create>`_

        :param migration_type: The migrator type to use in this migration
        :type migration_type: str or :class:`canvasapi.content_migration.Migrator`

        :rtype: :class:`canvasapi.content_migration.ContentMigration`
        """
        from canvasapi.content_migration import ContentMigration, Migrator

        if isinstance(migration_type, Migrator):
            kwargs['migration_type'] = migration_type.type
        elif isinstance(migration_type, string_types):
            kwargs['migration_type'] = migration_type
        else:
            raise TypeError('Parameter migration_type must be of type Migrator or str')

        response = self._requester.request(
            'POST',
            'groups/{}/content_migrations'.format(self.id),
            _kwargs=combine_kwargs(**kwargs)
        )

        response_json = response.json()
        response_json.update({'group_id': self.id})

        return ContentMigration(self._requester, response_json)
コード例 #3
0
 def test_parent_id_no_id(self, m):
     migration = ContentMigration(self.canvas._Canvas__requester, {'id': 1})
     with self.assertRaises(ValueError):
         migration._parent_id
コード例 #4
0
 def test_parent_type_no_type(self, m):
     migration = ContentMigration(self.canvas._Canvas__requester, {"id": 1})
     with self.assertRaises(ValueError):
         migration._parent_type