function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_delete_root_node(self):
# make sure we can't delete a root node
self.assertRaises(errors.NoPermission,
self.vgw.delete_node, self.root.id) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_restore_node(self):
"""Test restore_node."""
self.vgw.make_subdirectory(self.root.id, 'the dir name')
a_file = self.vgw.make_file(self.root.id, 'file.txt')
self.vgw.delete_node(a_file.id)
self.assertRaises(errors.DoesNotExist, self.vgw.get_node, a_file.id)
self.v... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_uploadjob(self):
"""Test get_uploadjob."""
a_file = self.vgw.make_file(self.root.id, 'the file name')
new_hash = self.factory.get_fake_hash()
crc = 12345
size = 100
# expected failures
f = self.vgw.make_uploadjob
self.assertRaises(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_user_uploadjobs(self):
"""Test get_user_uploadjobs."""
jobs = list(self.vgw.get_user_uploadjobs())
self.assertEqual(jobs, [])
file1 = self.vgw.make_file(self.root.id, 'the file1 name')
file2 = self.vgw.make_file(self.root.id, 'the file2 name')
file3 = self.vg... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_add_uploadjob_part(self):
"""Test add_uploadjob_part."""
file1 = self.vgw.make_file(self.root.id, 'the file1 name')
new_hash = self.factory.get_fake_hash()
crc = 12345
size = 100
job = self.vgw.make_uploadjob(
file1.id, file1.content_hash, new_hash, c... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_content_simple_handle_errors(self):
"""Test make_content."""
file_node = self.vgw.make_file(self.root.id, 'the file name')
old_hash = file_node.content_hash
file_id = file_node.id
new_hash = self.factory.get_fake_hash()
new_storage_key = uuid.uuid4()
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_content_updates_contentblob(self):
"""Contentblob is updated if needed when making content."""
filenode = self.vgw.make_file(self.root.id, 'the file name')
new_hash = self.factory.get_fake_hash()
new_storage_key = uuid.uuid4()
crc = 12345
size = 100
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_get_content(self):
"""Test the make and get content."""
hash = self.factory.get_fake_hash()
key = uuid.uuid4()
crc = 12345
size = 100
def_size = 10000
magic_hash = b'magic_hash'
content = self.vgw._make_content(hash, crc, size, def_size, key,... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_content(self):
"""Make file with contentblob.
This is similar to the way the updown server creates a file. But it's
all handled in one function after the upload.
"""
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid.... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_content_overwrite(self):
"""Make file with contentblob and overwite its existing content."""
name = 'filename.tif'
hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = 100
deflated_size = 10000
magic_has... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_content_enforces_quota(self):
"""Make file with contentblob enforces quota check (or not)."""
name = 'filename'
hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = deflated_size = 10000
f = self.vgw.make_file_w... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_move_node(self):
"""Test move_node method."""
root_id = self.vgw.get_root().id
dira1 = self.vgw.make_subdirectory(root_id, 'dira1')
dira2 = self.vgw.make_subdirectory(dira1.id, 'dira2')
dira3 = self.vgw.make_subdirectory(dira2.id, 'dira3')
dira4 = self.vgw.make_s... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_node_by_path(self):
"""Test get_node_by_path."""
root_id = self.root.id
dir1 = self.vgw.make_subdirectory(root_id, 'dir1')
file1 = self.vgw.make_file(root_id, 'file1.txt')
dir2 = self.vgw.make_subdirectory(dir1.id, 'dir2')
file2 = self.vgw.make_file(dir1.id, ... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_generation_delta_limit(self):
"""Test get generation delta."""
root_id = self.root.id
# get the generation before we add all the nodes
last_gen = self.vgw._get_user_volume().generation
dir1 = self.vgw.make_subdirectory(root_id, 'dir1')
file1 = self.vgw.make_f... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def make_file(i, n):
return self.vgw.make_file_with_content(i, n, hash, 123, 1, 1, key) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setup_volume(self):
"""Setup the volume used for this test case."""
self.gw = SystemGateway()
user = self.factory.make_user(max_storage_bytes=2000)
self.user = self.gw.get_user(user.id, session_id='QWERTY')
self.owner = self.user
# make a test file in the database
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setup_volume(self):
"""Setup the volume used for this test case."""
# create another user and share a folder with self.user
sharer = make_storage_user(
username='sharer', max_storage_bytes=2000)
self.owner = sharer
root = StorageObject.objects.get_root(sharer._use... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(RootReadWriteVolumeGatewayTestCase, self).setUp()
self.gw = SystemGateway()
user = self.factory.make_user()
self.user = self.gw.get_user(user.id, session_id='QWERTY')
# make a test file
vgw = self.user._gateway.get_root_gateway()
root = Stor... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_share(self):
"""Test make_share."""
sharer = self.factory.make_user(username='sharer')
vgw = ReadWriteVolumeGateway(self.user)
a_dir = vgw.make_subdirectory(vgw.get_root().id, 'the dir')
a_file = vgw.make_file(vgw.get_root().id, 'the file')
# test some obvio... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_undelete_volume(self):
"""Test Undelete Volume."""
vgw = ReadWriteVolumeGateway(self.user)
d2 = vgw.undelete_volume('recovered')
d = vgw.make_subdirectory(vgw.get_root().id, 'the dir')
vgw.delete_node(d.id)
d2 = vgw.undelete_volume('recovered')
vgw.delete... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(UDFReadWriteVolumeGatewayTestCase, self).setUp()
self.gw = SystemGateway()
db_user = self.factory.make_user()
self.user = self.gw.get_user(db_user.id, session_id='QWERTY')
# make a test file in the database
self.udf = self.factory.make_user_volume(
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_share(self):
"""Test make_share."""
user = self.factory.make_user(username='sharer')
a_dir = self.vgw.make_subdirectory(self.root.id, 'the dir')
share = self.vgw.make_share(a_dir.id, 'hi', user_id=user.id)
self.assertEqual(share.root_id, a_dir.id)
self.asser... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_share_offer(self):
"""Test make_share."""
a_dir = self.vgw.make_subdirectory(self.root.id, 'the dir')
share = self.vgw.make_share(a_dir.id, 'hi', user_id=None,
email='fake@email.com')
self.assertEqual(share.root_id, a_dir.id)
self... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_undelete_volume(self):
"""Test Undelete Volume from a UDF."""
udf = self.udf
udf_dao = DAOUserVolume(udf, self.user)
vgw = ReadWriteVolumeGateway(self.user, udf=udf_dao)
d = vgw.make_file(udf.root_node.id, 'thefile.txt')
vgw.delete_node(d.id)
vgw.undelete... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(ShareGatewayTestCase, self).setUp()
self.gw = SystemGateway()
user = self.factory.make_user()
self.user = self.gw.get_user(user.id, session_id='QWERTY')
self.sharer = make_storage_user(username='sharer')
self.othersharee = self.factory.make_user(use... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_user_gateway_get_shared_to(self):
"""Test UserGateway get_shared_to methods."""
shares = self.user._gateway.get_shared_to()
shares = list(shares)
self.assertEqual(len(shares), 2)
# this user only has shares shared to him
self.assertEqual(shares[0].shared_by.id, s... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_user_gateway_get_share(self):
"""Test UserGateway get_share methods."""
wrong_share = self.factory.make_share(
subtree=self.rw_node, shared_to=self.othersharee,
name='WriteShare', access=Share.VIEW)
# test with a share offer
shareoffer = self.factory.make... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_share_gateway(self):
"""Test the get_share_gateway method of a StorageUserGateway."""
vgw = self.user._gateway.get_share_gateway(self.r_share.id)
self.assertEqual(vgw.user, self.user)
self.assertEqual(vgw.owner.id, self.sharer.id)
self.assertEqual(vgw.root_id, self.r... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_share_not_accepted(self):
"""Shares that exist but are not accepted don't work."""
self.r_share.accepted = False
share_dao = SharedDirectory(self.r_share, by_user=self.sharer)
self.assertRaises(errors.NoPermission,
ReadWriteVolumeGateway, self.user, sha... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_readonly_share_fail(self):
"""Test make sure updates can't happen on a read only share"""
share_dao = SharedDirectory(self.r_share, by_user=self.sharer)
vgw = ReadWriteVolumeGateway(self.user, share=share_dao)
root_id = vgw.get_root().id
self.assertRaises(errors.NoPermis... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_node_not_on_volume(self):
"""Test to make sure nodes can't be retreived if they are not
on the volume."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
self.assertRaises(errors.DoesNotExist,
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_public_from_share_error(self):
"""Users cant make public files shared."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
a_file = sgw.make_file(sgw.get_root().id, 'hi')
self.assertRaises(errors.NoP... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_with_max_generation(self):
"""Test get_all_nodes with max_generation."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
root = sgw.get_root()
root_id = root.id
# make dirs and... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_with_max_generation_and_limit(self):
"""Test get_all_nodes with max_generation and limit."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
root = sgw.get_root()
root_id = root.id
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_chunked_with_changes(self):
"""Test chunked get_all_nodes with changes in the middle."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
root = sgw.get_root()
root_id = root.id
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_get_all_nodes_chunked_only_root(self):
"""Test chunked get_all_nodes with only one node, the root."""
share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
# sort them in the right order
nodes = sgw.get_a... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
super(GenerationsTestCase, self).setUp()
self.user = make_storage_user(username='testuser')
# make a test file
self.user_gw = StorageUserGateway(self.user)
self.vgw = self.user_gw.get_root_gateway() | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def volume(self):
return self.user._user.root_node.volume | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_subdirectory(self):
"""Test make_subdirectory increments generation."""
self.assertEqual(self.volume.generation, 0)
node = self.vgw.make_subdirectory(self.vgw.get_root().id, 'The Dir')
self.assertEqual(node.generation, 1)
self.assertEqual(self.volume.generation, 1) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_restore_file(self):
"""Test delete increments generation."""
self.assertEqual(self.volume.generation, 0)
node = self.vgw.make_file(self.vgw.get_root().id, 'The FIle')
node = self.vgw.delete_node(node.id)
node = self.vgw.restore_node(node.id)
self.assertEqual(node... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_make_file_with_content(self):
"""Test make_file_with_content increments generation."""
name = 'filename'
a_hash = self.factory.get_fake_hash()
storage_key = uuid.uuid4()
crc = 12345
size = 100
deflated_size = 10000
a_file = self.vgw.make_file_with... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_change_public_access(self):
"""Test change public access."""
a_file = self.vgw.make_file(self.vgw.get_root().id, 'the file name')
a_file = self.vgw.change_public_access(a_file.id, True)
f1 = StorageObject.objects.get(id=a_file.id)
self.assertEqual(f1.generation, 2)
... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_deltas_for_shares_with_moves(self):
"""Test deltas for shares where nodes have been moved out of them."""
# root nodes
root = self.vgw.get_root()
r_dir = self.vgw.make_subdirectory(root.id, 'dir')
r_subdir = self.vgw.make_subdirectory(r_dir.id, 'subdir')
r_file1 ... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def setUp(self):
"""Set up."""
super(MetricsTestCase, self).setUp()
self.user = make_storage_user(username='user1')
self.gw = ReadWriteVolumeGateway(self.user)
# put a recorder in the middle to see what was informed
self.informed = []
timing_metric.reporter.timin... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def _check(func):
"""Check func for decorator."""
closures = func.__closure__
# if it doesn't have any closures, it's not decorated at all
if closures is None:
return False
for closure in closures:
# if the cell content is the ... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_supervised_methods_volume_gateways(self):
"""Assure all these methods are supervised by timing decorator."""
superv = [
'get_root', 'get_user_volume', 'get_generation_delta', 'get_node',
'get_node_by_path', 'get_all_nodes',
'get_deleted_files', 'get_children'... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_call_simple_ok(self):
"""Supervise a successful operation and see all is reported ok."""
self.gw.get_root()
informed = self.informed[0]
self.assertEqual(informed[0], 'get_root')
self.assertTrue(isinstance(informed[1], float)) | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_call_complex(self):
"""Supervise an op with args and see all is reported ok."""
root_id = self.gw.get_root().id
self.gw.make_file(root_id, 'filename')
self.gw.get_child_by_name(root_id, 'filename', with_content=False)
for informed in self.informed:
if informe... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_call_on_shared(self):
"""Supervise an operation that is being made on a share."""
# create other user
other_user = make_storage_user(username='user2')
# make a share from default user to other user and accept it
root_id = self.gw.get_root().id
share = self.gw.ma... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def test_fix_udfs_with_gen_out_of_sync(self):
obj = self.factory.make_file()
obj.generation = obj.volume.generation + 1
obj.save()
user2 = self.factory.make_user()
obj2 = self.factory.make_file(owner=user2)
obj3 = self.factory.make_file(owner=user2)
obj2.generatio... | magicicada-bot/magicicada-server | [
6,
1,
6,
4,
1441315733
] |
def __init__(self, question, **options):
super().__init__(question, **options)
self.pos = options.get("pos")
self.rotate = options.get("rotate")
self.radius = options.get("radius")
self.color = options.get("color")
self.explode = options.get("explode")
self.sum = ... | Pierre-Sassoulas/django-survey | [
191,
133,
191,
35,
1489572975
] |
def get_results(self):
"""Return a formatted string for a tikz pgf-pie chart."""
pie = ""
for answer, cardinality in list(self.cardinality.items()):
if not answer:
ans = _("Left blank")
ans = Question2Tex.get_clean_answer(answer)
pie += f"{card... | Pierre-Sassoulas/django-survey | [
191,
133,
191,
35,
1489572975
] |
def get_caption_specifics(self):
return "{} '{}' ".format(_("for the question"), Question2Tex.html2latex(self.question.text)) | Pierre-Sassoulas/django-survey | [
191,
133,
191,
35,
1489572975
] |
def setUp(self):
super(UserAPITestCase, self).setUp()
self.anonymous_client = APIClient()
self.different_user = UserFactory.create(password=TEST_PASSWORD)
self.different_client = APIClient()
self.staff_user = UserFactory(is_staff=True, password=TEST_PASSWORD)
self.staff_... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def send_patch(self, client, json_data, content_type="application/merge-patch+json", expected_status=200):
"""
Helper method for sending a patch to the server, defaulting to application/merge-patch+json content_type.
Verifies the expected status and returns the response.
"""
# py... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def send_put(self, client, json_data, content_type="application/json", expected_status=204):
"""
Helper method for sending a PUT to the server. Verifies the expected status and returns the response.
"""
response = client.put(self.url, data=json.dumps(json_data), content_type=content_type... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def send_delete(self, client, expected_status=204):
"""
Helper method for sending a DELETE to the server. Verifies the expected status and returns the response.
"""
response = client.delete(self.url)
self.assertEqual(expected_status, response.status_code)
return response | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def _verify_profile_image_data(self, data, has_profile_image):
"""
Verify the profile image data in a GET response for self.user
corresponds to whether the user has or hasn't set a profile
image.
"""
template = '{root}/{filename}_{{size}}.{extension}'
if has_profi... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def setUp(self):
super(TestOwnUsernameAPI, self).setUp()
self.url = reverse("own_username_api") | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_username(self):
"""
Test that a client (logged in) can get her own username.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self._verify_get_own_username(16) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_username_not_logged_in(self):
"""
Test that a client (not logged in) gets a 401
when trying to retrieve their username.
"""
# verify that the endpoint is inaccessible when not logged in
self._verify_get_own_username(13, expected_status=401) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def setUp(self):
super(TestAccountsAPI, self).setUp()
self.url = reverse("accounts_api", kwargs={'username': self.user.username}) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def _verify_full_shareable_account_response(self, response, account_privacy=None, badges_enabled=False):
"""
Verify that the shareable fields from the account are returned
"""
data = response.data
self.assertEqual(12, len(data))
# public fields (3)
self.assertEqu... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def _verify_full_account_response(self, response, requires_parental_consent=False, year_of_birth=2000):
"""
Verify that all account fields are returned (even those that are not shareable).
"""
data = response.data
self.assertEqual(25, len(data))
# public fields (3)
... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_unsupported_methods(self):
"""
Test that DELETE, POST, and PUT are not supported.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self.assertEqual(405, self.client.put(self.url).status_code)
self.assertEqual(405, self.client.post(self.u... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_unknown_user(self, api_client, user):
"""
Test that requesting a user who does not exist returns a 404.
"""
client = self.login_client(api_client, user)
response = client.get(reverse("accounts_api", kwargs={'username': "does_not_exist"}))
self.assertE... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_by_email(self, api_client, user):
"""
Test that requesting a user email search works.
"""
client = self.login_client(api_client, user)
self.create_mock_profile(self.user)
set_user_preference(self.user, ACCOUNT_VISIBILITY_PREF_KEY, PRIVATE_VISIBILITY)
... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_different_user_visible(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
This is the case when default_visibility is set to "all_users".
"""
self.different_client.login(username=self.different_user.username, pas... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_different_user_private(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
This is the case when default_visibility is set to "private".
"""
self.different_client.login(username=self.different_user.username, passw... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_private_visibility(self, api_client, requesting_username, preference_visibility):
"""
Test the return from GET based on user visibility setting.
"""
def verify_fields_visible_to_all_users(response):
"""
Confirms that private fields are private... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_custom_visibility_over_age(self, api_client, requesting_username):
self.create_mock_profile(self.user)
# set user's custom visibility preferences
set_user_preference(self.user, ACCOUNT_VISIBILITY_PREF_KEY, CUSTOM_VISIBILITY)
shared_fields = ("bio", "language_proficiencies", "nam... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_custom_visibility_under_age(self, api_client, requesting_username):
self.create_mock_profile(self.user)
year_of_birth = self._set_user_age_to_10_years(self.user)
# set user's custom visibility preferences
set_user_preference(self.user, ACCOUNT_VISIBILITY_PREF_KEY, CUSTOM_VISIBI... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_default(self):
"""
Test that a client (logged in) can get her own account information (using default legacy profile information,
as created by the test UserFactory).
"""
def verify_get_own_information(queries):
"""
Internal helper to ... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_get_account_empty_string(self):
"""
Test the conversion of empty strings to None for certain fields.
"""
legacy_profile = UserProfile.objects.get(id=self.user.id)
legacy_profile.country = ""
legacy_profile.state = ""
legacy_profile.level_of_education = ""... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_account_disallowed_user(self, api_client, user):
"""
Test that a client cannot call PATCH on a different client's user account (even with
is_staff access).
"""
client = self.login_client(api_client, user)
self.send_patch(client, {}, expected_status=403) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_account_unknown_user(self, api_client, user):
"""
Test that trying to update a user who does not exist returns a 403.
"""
client = self.login_client(api_client, user)
response = client.patch(
reverse("accounts_api", kwargs={'username': "does_not_exist"}... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_account(self, field, value, fails_validation_value=None, developer_validation_message=None):
"""
Test the behavior of patch, when using the correct content_type.
"""
client = self.login_client("client", "user")
if field == 'account_privacy':
# Ensure t... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_account_noneditable(self):
"""
Tests the behavior of patch when a read-only field is attempted to be edited.
"""
client = self.login_client("client", "user")
def verify_error_response(field_name, data):
"""
Internal helper to check the erro... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_account_empty_string(self):
"""
Tests the behavior of patch when attempting to set fields with a select list of options to the empty string.
Also verifies the behaviour when setting to None.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def get_name_change_info(expected_entries):
"""
Internal method to encapsulate the retrieval of old names used
"""
legacy_profile = UserProfile.objects.get(id=self.user.id)
name_change_info = legacy_profile.get_meta()["old_names"]
self.assertEqual(... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_email(self):
"""
Test that the user can request an email change through the accounts API.
Full testing of the helper method used (do_email_change_request) exists in the package with the code.
Here just do minimal smoke testing.
"""
client = self.login_clien... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_invalid_email(self, bad_email):
"""
Test a few error cases for email validation (full test coverage lives with do_email_change_request).
"""
client = self.login_client("client", "user")
# Try changing to an invalid email to make sure error messages are appropriate... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_duplicate_email(self, do_email_change_request):
"""
Test that same success response will be sent to user even if the given email already used.
"""
existing_email = "same@example.com"
UserFactory.create(email=existing_email)
client = self.login_client("clie... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_invalid_language_proficiencies(self, patch_value, expected_error_message):
"""
Verify we handle error cases when patching the language_proficiencies
field.
"""
if six.PY3:
expected_error_message = six.text_type(expected_error_message).replace('unicode',... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_patch_serializer_save_fails(self, serializer_save):
"""
Test that AccountUpdateErrors are passed through to the response.
"""
serializer_save.side_effect = [Exception("bummer"), None]
self.client.login(username=self.user.username, password=TEST_PASSWORD)
error_re... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_convert_relative_profile_url(self):
"""
Test that when TEST_PROFILE_IMAGE_BACKEND['base_url'] begins
with a '/', the API generates the full URL to profile images based on
the URL of the request.
"""
self.client.login(username=self.user.username, password=TEST_PAS... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_parental_consent(self, api_client, requesting_username, has_full_access):
"""
Verifies that under thirteens never return a public profile.
"""
client = self.login_client(api_client, requesting_username)
year_of_birth = self._set_user_age_to_10_years(self.user)
s... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def setUp(self):
super(TestAccountAPITransactions, self).setUp()
self.client = APIClient()
self.user = UserFactory.create(password=TEST_PASSWORD)
self.url = reverse("accounts_api", kwargs={'username': self.user.username}) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_update_account_settings_rollback(self, mock_email_change):
"""
Verify that updating account settings is transactional when a failure happens.
"""
# Send a PATCH request with updates to both profile information and email.
# Throw an error from the method that is used to p... | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def setUp(self):
super(UsernameReplacementViewTests, self).setUp()
self.service_user = UserFactory(username=self.SERVICE_USERNAME)
self.url = reverse("username_replacement") | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def call_api(self, user, data):
""" Helper function to call API with data """
data = json.dumps(data)
headers = self.build_jwt_headers(user)
return self.client.post(self.url, data, content_type='application/json', **headers) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def test_bad_schema(self, mapping_data):
""" Verify the endpoint rejects bad data schema """
data = {
"username_mappings": mapping_data
}
response = self.call_api(self.service_user, data)
self.assertEqual(response.status_code, 400) | appsembler/edx-platform | [
12,
17,
12,
30,
1412683746
] |
def _select(self):
select_str = """
SELECT row_number() OVER() as id,
a.type_id AS type_id,
a.vehicle_id AS vehicle_id,
a.driver_id AS driver_id,
a.co_driver_id AS co_driver_id,
a.date_start AS date_start,
a.date_end AS d... | open-synergy/opensynid-fleet | [
2,
12,
2,
4,
1460253955
] |
def _where(self):
where_str = """
"""
return where_str | open-synergy/opensynid-fleet | [
2,
12,
2,
4,
1460253955
] |
def _group_by(self):
group_str = """
GROUP BY a.type_id,
a.vehicle_id,
a.driver_id,
a.co_driver_id,
a.date_start,
a.date_end,
a.real_date_depart,
... | open-synergy/opensynid-fleet | [
2,
12,
2,
4,
1460253955
] |
def remove_permissions(apps, _unused):
Permission = apps.get_model("auth.Permission")
Permission.objects.filter(
codename__in=(
"add_follower",
"change_follower",
"view_follower",
"delete_follower",
"add_scenario",
"change_scenario"... | frePPLe/frePPLe | [
394,
214,
394,
42,
1378966013
] |
def setUp(self):
if not os.path.exists(os.path.join(TESTDATA_PATH, "exports")):
os.makedirs(os.path.join(TESTDATA_PATH, "exports"))
self.movie = dict()
self.movie["title"] = "Fight Club"
self.movie["imdb"] = dict()
self.movie["imdb"]["id"] = "tt0137523"
self.m... | StegSchreck/RatS | [
227,
30,
227,
42,
1486496246
] |
def test_init(self, browser_mock, base_init_mock):
ICheckMoviesRatingsInserter(None)
self.assertTrue(base_init_mock.called) | StegSchreck/RatS | [
227,
30,
227,
42,
1486496246
] |
def test_insert(
self, browser_mock, base_init_mock, site_mock, impex_mock, select_mock | StegSchreck/RatS | [
227,
30,
227,
42,
1486496246
] |
def __init__(self, cr, uid, name, context=None):
super(ReportAccountPayment, self).__init__(cr, uid, name,
context=context)
self.localcontext.update({
'get_text_amount': self._get_text_amount,
}) | ClearCorp/odoo-clearcorp | [
14,
44,
14,
5,
1400190481
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.