function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def create_value(self, history):
return (history.values[-1] + 1) % 32 | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def __init__(self, type):
self.type = type | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def __init__(self):
pass | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def emit_dynasm(self, value):
raise NotImplementedError() | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def __init__(self, family):
self.family = family | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def emit_dynasm(self, value, allow_dynamic=True):
# randomly choose dynamic vs static notation
if random.choice((True, False)) or not allow_dynamic or ('SP' in self.family and value != 31):
return self.emit_gas(value)
else:
if self.family == "WX":
self.fam... | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def emit_gas(self, value):
return "{}".format(value) | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def emit_gas(self, value):
return "{}".format(value) | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def emit_gas(self, value):
return value.lower() | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def make_wide_integer(bit64):
return random.randrange(0, 1<<16) << random.randrange(0, 64 if bit64 else 32, 16) | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def make_logical_imm(bit64):
element_size = random.choice([2, 4, 8, 16, 32, 64] if bit64 else [2, 4, 8, 16, 32])
ones = random.randrange(1, element_size)
rotation = random.randrange(0, element_size)
element = [0] * (element_size - ones) + [1] * ones
l = element * ((64 if bit64 else 32) // element_s... | CensoredUsername/dynasm-rs | [
586,
43,
586,
11,
1467672562
] |
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.lv_load_area_group = kwargs.get('lv_load_area_group', None)
self.id_db = self.grid.cable_distributors_count() + 1 | openego/dingo | [
28,
4,
28,
53,
1450440330
] |
def pypsa_id(self):
""" :obj:`str`: Returns ...#TODO
"""
return '_'.join(['MV', str(self.grid.id_db),
'cld', str(self.id_db)]) | openego/dingo | [
28,
4,
28,
53,
1450440330
] |
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.string_id = kwargs.get('string_id', None)
self.branch_no = kwargs.get('branch_no', None)
self.load_no = kwargs.get('load_no', None)
self.id_db = self.grid.cable_distributors_count() + 1
self.in_building = kwar... | openego/dingo | [
28,
4,
28,
53,
1450440330
] |
def test_course_key(self):
"""
Test CourseKey
"""
key = CourseKey.from_string('org.id/course_id/run')
self.assertEqual(key.org, 'org.id')
key = CourseKey.from_string('course-v1:org.id+course_id+run')
self.assertEqual(key.org, 'org.id') | edx/opaque-keys | [
7,
18,
7,
7,
1400865894
] |
def put(self, **kwargs):
ndb.Model.put(self, **kwargs)
self._setup()
try:
self.put_index()
except:
print 'error on saving document index' | ioGrow/iogrowCRM | [
28,
16,
28,
38,
1463922513
] |
def put_index(self, data=None):
""" index the element at each"""
empty_string = lambda x: x if x else ""
collaborators = " ".join(self.collaborators_ids)
organization = str(self.organization.id())
if data:
search_key = ['topics', 'tags']
for key in search_... | ioGrow/iogrowCRM | [
28,
16,
28,
38,
1463922513
] |
def get_schema(cls, user_from_email, request):
note = cls.get_by_id(int(request.id))
if note is None:
raise endpoints.NotFoundException('Note not found.')
author = AuthorSchema(
google_user_id=note.author.google_user_id,
display_name=note.author.display_name,
... | ioGrow/iogrowCRM | [
28,
16,
28,
38,
1463922513
] |
def insert(cls, user_from_email, request):
parent_key = ndb.Key(urlsafe=request.about)
note_author = Userinfo()
note_author.display_name = user_from_email.google_display_name
note_author.photo = user_from_email.google_public_profile_photo_url
note = Note(
owner=user_... | ioGrow/iogrowCRM | [
28,
16,
28,
38,
1463922513
] |
def list_by_parent(cls, parent_key, request):
topic_list = []
topic_edge_list = Edge.list(
start_node=parent_key,
kind='topics',
limit=request.topics.limit,
pageToken=request.topics.pageToken
)
for edge in topic_edge_list['items']:
... | ioGrow/iogrowCRM | [
28,
16,
28,
38,
1463922513
] |
def __init__(self, id, name, root_id, shared_by_id, shared_to_id,
access, accepted):
"""Initialize an instance."""
self.id = id
self.name = name
self.root_id = root_id
self.shared_by_id = shared_by_id
self.shared_to_id = shared_to_id
self.access =... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def __init__(self, owner_id, id, root_id, path):
"""Initialize an instance."""
self.owner_id = owner_id
self.id = id
self.root_id = root_id
self.path = path | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def __init__(self):
super(DummyNotifier, self).__init__()
self.notifications = [] | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def reset(self):
self.notifications = [] | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(GatewayBaseTestCase, self).setUp()
self.dummy_notifier = DummyNotifier()
self.gw = GatewayBase(notifier=self.dummy_notifier) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_user_username(self):
"""Test get_user with username"""
user = self.factory.make_user()
user2 = self.gw.get_user(username=user.username, session_id='QWERTY')
self.assertEqual(user.id, user2.id)
self.assertEqual(user.username, user2.username)
self.assertEqual(u... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_user_locked_ignore_lock(self):
"""Test get_user with a locked user, but ignore the lock."""
user = self.factory.make_user(locked=True)
nuser = self.gw.get_user(
user.id, session_id='QWERTY', ignore_lock=True)
self.assertEqual(user.id, nuser.id) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_queue_new_generation(self):
"""When a new volume generation."""
vol_id = uuid.uuid4()
with fsync_commit():
self.gw.queue_new_generation(1, vol_id, 3)
self.assertEqual(self.dummy_notifier.notifications, [
VolumeNewGeneration(1, vol_id, 3, self.gw.session_i... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_queue_share_created(self):
"""Test event generated when a share is created."""
self._test_queue_share_event(ShareCreated, 'queue_share_created') | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_queue_share_accepted(self):
"""Test event generated when a share is accepted."""
self._test_queue_share_event(ShareAccepted, 'queue_share_accepted') | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_queue_udf_create(self):
"""Test event generated when a UDF has been created."""
owner_id = 10
udf_id = uuid.uuid4()
root_id = uuid.uuid4()
suggested_path = 'foo/bar/baz'
udf = FakeUDF(owner_id, root_id, udf_id, suggested_path)
with fsync_commit():
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(EventNotificationTest, self).setUp()
self.user = make_storage_user(username='user1')
self.dummy_notifier = DummyNotifier()
self.gw = GatewayBase(
session_id=uuid.uuid4(), notifier=self.dummy_notifier)
self.vgw = ReadWriteVolumeGateway(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_queue_new_generation_generation_None(self):
"""When a new volume generation is None."""
vol_id = uuid.uuid4()
with fsync_commit():
self.gw.queue_new_generation(1, vol_id, None)
self.assertEqual(self.dummy_notifier.notifications, [
VolumeNewGeneration(1, v... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_handle_node_change_from_share(self):
"""Test the handle_node_change."""
self.setup_shares()
node = StorageObject.objects.get(id=self.d3.id)
user1 = make_storage_user(username=self.user1.username)
share = user1.get_share(self.share1.id)
vgw = ReadWriteVolumeGatewa... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_magic_content(self):
"""Make sure make_file with magic content sends a notification."""
cb = self.factory.make_content_blob(
content='FakeContent', magic_hash=b'magic')
with fsync_commit():
f = self.vgw.make_file(self.root.id, 'filename', hash=cb.h... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_delete_file_notifications(self):
"""Make sure delete_file sends notifications."""
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = 100
deflated_size = 10000
with fsync_commit():
f = se... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_subdirectory_notification(self):
"""Make sure make_subdirectory sends notifications."""
# the root node gets a notification as a directory content change
with fsync_commit():
d = self.vgw.make_subdirectory(self.root.id, 'dirname')
self.assertEqual(self.dummy_not... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_delete_directory_notification(self):
"""Make sure make_subdirectory sends notifications."""
with fsync_commit():
d = self.vgw.make_subdirectory(self.root.id, 'dir')
self.dummy_notifier.reset()
with fsync_commit():
d = self.vgw.delete_node(d.id)
se... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_move_notification_with_overwrite(self):
"""Make sure moves send the corrent notifications."""
root_id = self.vgw.get_root().id
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = 111111111
deflated_s... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_content(self):
"""Ensure file creation with content sends corrent notifications."""
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = 111111111
deflated_size = 10000
magic_hash = b'm... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_content(self):
"""Make sure make_content sends correct notifications."""
with fsync_commit():
filenode = self.vgw.make_file(self.root.id, 'the file name')
self.dummy_notifier.reset()
new_hash = self.factory.get_fake_hash()
new_storage_key = uuid.uuid4()
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(SystemGatewayTestCase, self).setUp()
self.gw = SystemGateway() | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_create_or_update_user_update(self):
"""Test the basic make user method"""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
# update the user info.
usr = StorageUser.objects.get(id=user.id)
usr.status = STATUS... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_claim_shareoffer(self):
"""Test that the claim_shareoffer function works properly.
A share_offer isn't a direct share to a user. Instead, its offered in
that an share is created but only sent to an email address. However,
any user can accept the share as long as it hasn't been ... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_download(self):
"""The make_download() method creates a Download object."""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factory.make_user_volume(
owner=user._user, path='~/path/name')
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_download(self):
"""The get_download() method can find downloads by user, volume,
path and URL or key.
"""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factory.make_user_volume(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_old_song_with_multiple_download_records(self):
"""Old songs may have multiple download records. Get the latest."""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factory.make_user_volume(
owner=u... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_download_with_same_key_and_different_url(self):
"""The get_download() method can find downloads by user, volume,
path and URL or key.
"""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factor... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_update_download_status(self):
"""The update_download() method can update a download's status."""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factory.make_user_volume(
owner=user._user, path='~/spa... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_update_download_error_message(self):
"""The update_download() method can update a download's error
message."""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
udf = self.factory.make_user_volume(
owner=u... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_node(self):
"""Test the get_node method."""
user = self.gw.create_or_update_user(
'username', visible_name='Visible Name', max_storage_bytes=1)
sgw = SystemGateway()
root = StorageObject.objects.get_root(user._user)
node = root.make_file('TheName', mimety... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_cleanup_abandoned_uploadjobs(self):
"""Test the cleanup_uploadjobs method."""
right_now = now()
crc = 12345
size = 100
def_size = 100
for uid in range(0, 10):
suser = self.factory.make_user(
username='testuser_%d' % uid, max_storage_by... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(SystemGatewayPublicFileTestCase, self).setUp()
self.gw = SystemGateway()
self.user1 = make_storage_user(username='sharer')
self.vgw = ReadWriteVolumeGateway(self.user1)
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_public_file_no_content(self):
"""Test get_public_file when file has no content."""
file_dao = self.vgw.change_public_access(self.file.id, True)
self.file.content_blob = None
self.file.save()
self.assertRaises(errors.DoesNotExist,
self.gw.get... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_public_file(self):
"""Tests for get_public_file."""
file_dao = self.vgw.change_public_access(self.file.id, True)
self.assertIsNotNone(file_dao.public_uuid)
public_key = file_dao.public_key
# Once a file has been made public, it can be looked up by its ID.
fil... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(SystemGatewayPublicDirectoryTestCase, self).setUp()
self.gw = SystemGateway()
self.user1 = make_storage_user(username='sharer')
self.vgw = ReadWriteVolumeGateway(self.user1)
self.root = self.vgw.get_root()
dir1 = self.vgw.make_subdirectory(self.root... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_public_directory(self):
"""Tests for get_public_directory."""
dir_dao = self.vgw.change_public_access(
self.dir.id, True, allow_directory=True)
self.assertIsNotNone(dir_dao.public_uuid)
public_key = dir_dao.public_key
# If I don't do this, the test fails
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(StorageUserGatewayTestCase, self).setUp()
self.user = make_storage_user(username='testuser')
self.gw = StorageUserGateway(self.user) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_udf_gateway_None(self):
"""Make sure method returns None and no Error."""
vgw = self.gw.get_udf_gateway(uuid.uuid4())
self.assertEqual(vgw, None) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_accept_share(self):
"""Test accepting a direct share."""
user1 = self.factory.make_user(username='sharer')
root = StorageObject.objects.get_root(user1)
share = self.factory.make_share(
subtree=root, shared_to=self.user._user, name='Share',
accepted=False)... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_delete_share(self):
"""Test delete shares from share-er and share-ee"""
user1 = self.factory.make_user(username='sharer')
root = StorageObject.objects.get_root(user1)
share = self.factory.make_share(
subtree=root, shared_to=self.user._user, name='Share')
shar... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_udf(self):
"""Test make_udf method."""
udf = self.gw.make_udf('~/path/name')
self.assertEqual(udf.owner_id, self.user.id)
self.assertEqual(udf.path, '~/path/name')
self.assertNotEqual(udf.when_created, None)
# make sure the same UDF is created
udf2 =... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_udf(self):
"""Test make and get udf methods."""
udf = self.gw.make_udf('~/path/name')
udf2 = self.gw.get_udf(udf.id)
self.assertEqual(udf.id, udf2.id)
self.assertEqual(udf.path, udf2.path) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_udfs(self):
"""Test get_udfs method."""
for i in range(10):
self.gw.make_udf('~/path/to/file/name %s' % i)
udfs = self.gw.get_udfs()
udfs = list(udfs)
self.assertEqual(len(udfs), 10)
for udf in udfs:
self.gw.delete_udf(udf.id)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_delete_udf_with_children(self):
"""Test delete_udf method."""
udf = self.gw.make_udf('~/path/name')
vgw = ReadWriteVolumeGateway(self.user, udf=udf)
a_dir = vgw.make_subdirectory(vgw.root_id, 'subdir')
vgw.make_file(a_dir.id, 'file')
self.gw.delete_udf(udf.id)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_noaccess_inactive_user(self):
"""Make sure NoAccess is rasied when the user is inactive."""
self.user.is_active = False
self.assertRaises(errors.NoPermission, self.gw.make_udf, '~/p/n')
self.assertRaises(errors.NoPermission, self.gw.accept_share, 1)
self.assertRaises(err... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_delete_related_shares_lotsofchildren(self):
"""Make sure the query splitting does it's job."""
vgw = self.gw.get_root_gateway()
dir1 = vgw.make_subdirectory(vgw.get_root().id, 'shared1')
# make lots of children
for i in xrange(300):
vgw.make_subdirectory(dir1... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_public_files(self):
"""Test get_public_files method."""
vgw = self.gw.get_root_gateway()
root = StorageObject.objects.get_root(self.user._user)
node = root.make_file('TheName', mimetype='fakemime')
vgw.change_public_access(node.id, True)
nodes = list(self.gw.... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_share_generation(self):
"""Test the get_share_generation method."""
user1 = self.factory.make_user(username='sharer')
root = StorageObject.objects.get_root(user1)
share = self.factory.make_share(
subtree=root, shared_to=self.user._user, name='Share')
shar... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_reusable_content_no_blob(self):
"""No blob at all, can not reuse."""
blobexists, storage_key = self.gw._get_reusable_content(
b'hash_value', b'magic')
self.assertFalse(blobexists)
self.assertEqual(storage_key, None) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_reusable_content_same_owner_no_magic(self):
"""Test update_content will reuse owned content, even with no magic."""
hash_value = self.factory.get_fake_hash()
node = self._make_file_with_content(hash_value)
blobexists, storage_key = self.gw.is_reusable_content(hash_value, None)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_reusable_content_different_owner_no_magic(self):
"""Test update_content will not reuse someone elses content."""
user2 = make_storage_user(
username='testuserX', max_storage_bytes=2 ** 32)
assert user2.id != self.user.id
hash_value = self.factory.get_fake_hash()
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__get_reusable_content_no_blob(self):
"""No blob at all, can not reuse."""
blobexists, blob = self.gw._get_reusable_content(
b'hash_value', b'magic')
self.assertFalse(blobexists)
self.assertEqual(blob, None) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__get_reusable_content_same_owner_with_magic(self):
"""Test update_content will reuse owned content."""
hash_value = self.factory.get_fake_hash()
node = self._make_file_with_content(hash_value, magic_hash=b'magic')
blobexists, blob = self.gw._get_reusable_content(hash_value, 'mag... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__get_reusable_content_different_owner_with_magic(self):
"""Test update_content will reuse someone elses content with magic."""
user2 = make_storage_user(
username='testuserX', max_storage_bytes=2 ** 32)
assert user2.id != self.user.id
hash_value = self.factory.get_f... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(ReadWriteVolumeGatewayUtilityTests, self).setUp()
self.gw = SystemGateway()
self.user = make_storage_user(
username='testuser', max_storage_bytes=2000)
self.vgw = self.user._gateway.get_root_gateway()
self.root = self.vgw.get_root() | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_only_from_volume(self):
"""Test get_all_nodes."""
# make some files on a UDF...
udf = self.factory.make_user_volume(
owner=self.user._user, path='~/thepath/thename')
udf_dao = DAOUserVolume(udf, self.user)
udf_vgw = ReadWriteVolumeGateway(self.u... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_with_mimetype(self):
"""Test get_all_nodes with mimetype filter."""
hash = self.factory.get_fake_hash()
key = uuid.uuid4()
root_id = self.vgw.get_root().id
def mkfile(i, m):
return self.vgw.make_file_with_content(
root_id, 'file%s' % ... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def mkfile(i, m):
return self.vgw.make_file_with_content(
root_id, 'file%s.tif' % i, hash, 1, 1, 1, key, mimetype=m) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_with_content_and_mimetype(self):
"""Test get_all_nodes with mimetype filter."""
hash = self.factory.get_fake_hash()
key = uuid.uuid4()
root_id = self.vgw.get_root().id
def mkfile(i, m):
return self.vgw.make_file_with_content(
root_id,... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_with_limit(self):
"""Test get_all_nodes with a limit."""
root = self.vgw.get_root()
root_id = root.id
# make dirs and put files in them
dirs = []
files = []
for i in range(10):
d = self.vgw.make_subdirectory(root_id, '%sd' % i)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_with_max_generation_and_limit_only_from_volume(
self):
"""Test get_all_nodes wiht max_generation and limit for a UDF."""
# make some files on a UDF...
udf = self.factory.make_user_volume(
owner=self.user._user, path='~/thepath/thename')
udf_... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_chunked_with_move_middle(self):
"""Test chunked get_all_nodes with a move in the middle."""
root = self.vgw.get_root()
root_id = root.id
# make dirs and put files in them
dirs = []
files = []
for i in range(10):
d = self.vgw.make... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_chunked_only_root_in_volume(self):
"""Test chunked get_all_nodes with only one node, the root."""
udf = self.factory.make_user_volume(
owner=self.user._user, path='~/thepath/thename')
udf_dao = DAOUserVolume(udf, self.user)
udf_vgw = ReadWriteVolumeGate... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def mkfile(dir_id, i):
return self.vgw.make_file(dir_id, 'file%s.txt' % i) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setup_shares(self):
"""Setup some shares for moves from shares."""
d = self.vgw.make_tree(self.root.id, '/a/b/c/d')
y = self.vgw.make_tree(self.root.id, '/x/y')
usera = make_storage_user(username='sharee1')
userb = make_storage_user(username='sharee2')
userc = make_s... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_move_from_share_2(self):
"""Test _make_move_from_share method.
Move into a child of the node's folder.
"""
d, y, sa, sb, sc = self.setup_shares()
f1 = self.vgw.make_file(d.id, 'file.txt')
np = self.vgw.make_tree(d.id, '/q/w/e/r/t/y')
self.assertTrue(np.f... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_change_public_access_file(self):
"""Test the basics of changing public access to a file."""
a_file = self.vgw.make_file(self.root.id, 'a-file.txt')
# It has no public ID
self.assertIsNone(a_file.public_uuid)
# It now has a public ID
self.assertIsNotNone(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_change_public_access_directory(self):
"""Test that directories can be made public if explicitly requested."""
a_dir = self.vgw.make_tree(self.root.id, '/x')
# It has no public ID
self.assertIsNone(a_dir.public_uuid)
# It now has a public ID
self.assertIsNotNone(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(CommonReadWriteVolumeGatewayApiTest, self).setUp()
self.gw = SystemGateway()
user = make_storage_user(username='testuser', max_storage_bytes=2000)
self.user = self.gw.get_user(user.id)
self.setup_volume() | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def tweak_users_quota(self, dao_user, max_bytes, used_bytes=0):
"""Utility to toy with the user's quota."""
StorageUser.objects.filter(id=dao_user.id).update(
max_storage_bytes=max_bytes, used_storage_bytes=used_bytes)
dao_user._load() | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__get_root_node(self):
"""Test _get_root_node method."""
node = self.vgw._get_root_node()
self.assertEqual(node, self.root) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_user_volume(self):
"""Test get_user_volume method."""
vol = self.vgw.get_user_volume()
self.assertTrue(isinstance(vol, DAOUserVolume))
self.assertEqual(vol.id, self.root.volume_id) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__node_finder(self):
"""Test the _node_finder method."""
nodes = StorageObject.objects.filter(id=self.file.id)
result = self.vgw._node_finder(nodes)
node = self.vgw._get_node_from_result(result)
self.assertEqual(node.id, self.file.id)
self.assertEqual(node.content... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test__get_node_with_parent(self):
nodes = StorageObject.objects.filter(id=self.file.id)
result = self.vgw._node_finder(nodes, with_parent=True)
node = self.vgw._get_node_from_result(result)
self.assertEqual(node.id, self.file.id)
self.assertEqual(node.content_hash, self.file.... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_check_has_children(self):
"""Test the check_has_children function."""
a_dir = self.vgw.make_subdirectory(
self.root.id, StorageObject.DIRECTORY)
self.assertTrue(
self.vgw.check_has_children(self.root.id, StorageObject.FILE))
self.assertTrue(
s... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_node(self):
"""Test get_node method."""
# make sure it returns the root node when special 'root' is used:
root_node = self.vgw.get_node('root')
self.assertEqual(root_node.id, self.vgw.get_root().id)
node = self.vgw.get_node(self.file.id, with_content=True)
se... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_tree(self):
"""Test make_tree method."""
node = self.vgw.make_tree(self.root.id, '/a/b/c')
self.assertEqual(node.full_path, '/a/b/c')
node = self.vgw.make_tree(self.root.id, '/')
self.assertEqual(node.id, self.root.id) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_magic(self):
"""Test make_file method."""
cb = self.factory.make_content_blob(
content='FakeContent', magic_hash=b'magic')
# make enough room
self.tweak_users_quota(self.owner, cb.deflated_size)
node = self.vgw.make_file(self.root.id, 'the file... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_subdirectory(self):
"""Test make_subdirectory method."""
node = self.vgw.make_subdirectory(self.root.id, 'the file name')
self.assertTrue(isinstance(node, DirectoryNode))
self.assertEqual(node.name, 'the file name')
self.assertEqual(node.parent_id, self.root.id)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.