Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"))
def test_parent_id_no_id(self, m):
migration = ContentMigration(self.canvas._Canvas__requester, {'id': 1})
with self.assertRaises(ValueError):
migration._parent_id
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"))
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)
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)
`_
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
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)
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),
)
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)