How to use the canvasapi.content_migration.ContentMigration function in canvasapi

To help you get started, we’ve selected a few canvasapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ucfopen / canvasapi / tests / test_account.py View on Github external
def test_create_content_migration(self, m):
        register_uris({"account": ["create_content_migration"]}, m)

        content_migration = self.account.create_content_migration("dummy_importer")

        self.assertIsInstance(content_migration, ContentMigration)
        self.assertTrue(hasattr(content_migration, "migration_type"))
github ucfopen / canvasapi / tests / test_content_migration.py View on Github external
def test_parent_id_no_id(self, m):
        migration = ContentMigration(self.canvas._Canvas__requester, {'id': 1})
        with self.assertRaises(ValueError):
            migration._parent_id
github ucfopen / canvasapi / tests / test_course.py View on Github external
def test_create_content_migration(self, m):
        register_uris({"course": ["create_content_migration"]}, m)

        content_migration = self.course.create_content_migration("dummy_importer")

        self.assertIsInstance(content_migration, ContentMigration)
        self.assertTrue(hasattr(content_migration, "migration_type"))
github ucfopen / canvasapi / canvasapi / user.py View on Github external
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",
            "users/{}/content_migrations".format(self.id),
            _kwargs=combine_kwargs(**kwargs),
        )

        response_json = response.json()
        response_json.update({"user_id": self.id})

        return ContentMigration(self._requester, response_json)
github ucfopen / canvasapi / canvasapi / group.py View on Github external
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)
github ucfopen / canvasapi / canvasapi / content_migration.py View on Github external
`_

            or `PUT /api/v1/users/:user_id/content_migrations/:id
            `_

        :returns: True if the migration was updated, False otherwise.
        :rtype: bool
        """
        response = self._requester.request(
            'PUT',
            '{}s/{}/content_migrations/{}'.format(self._parent_type, self._parent_id, self.id),
            _kwargs=combine_kwargs(**kwargs)
        )

        if 'migration_type' in response.json():
            super(ContentMigration, self).set_attributes(response.json())
            return True
        else:
            return False
github ucfopen / canvasapi / canvasapi / course.py View on Github external
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",
            "courses/{}/content_migrations".format(self.id),
            _kwargs=combine_kwargs(**kwargs),
        )

        response_json = response.json()
        response_json.update({"course_id": self.id})

        return ContentMigration(self._requester, response_json)
github ucfopen / canvasapi / canvasapi / group.py View on Github external
def get_content_migrations(self, **kwargs):
        """
        List content migrations that the current account can view or manage.

        :calls: `GET /api/v1/groups/:group_id/content_migrations/ \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.content_migration.ContentMigration`
        """
        from canvasapi.content_migration import ContentMigration

        return PaginatedList(
            ContentMigration,
            self._requester,
            "GET",
            "groups/{}/content_migrations".format(self.id),
            {"group_id": self.id},
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / account.py View on Github external
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",
            "accounts/{}/content_migrations".format(self.id),
            _kwargs=combine_kwargs(**kwargs),
        )

        response_json = response.json()
        response_json.update({"account_id": self.id})

        return ContentMigration(self._requester, response_json)