当前位置: 首页>>代码示例>>Python>>正文


Python base.reverse方法代码示例

本文整理汇总了Python中django.urls.base.reverse方法的典型用法代码示例。如果您正苦于以下问题:Python base.reverse方法的具体用法?Python base.reverse怎么用?Python base.reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.urls.base的用法示例。


在下文中一共展示了base.reverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_locus_lists

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_locus_lists(self):
        url = reverse(locus_lists)
        self.check_require_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        locus_lists_dict = response.json()['locusListsByGuid']
        self.assertSetEqual(set(locus_lists_dict.keys()), {LOCUS_LIST_GUID})

        locus_list = locus_lists_dict[LOCUS_LIST_GUID]
        fields = {'numProjects'}
        fields.update(LOCUS_LIST_FIELDS)
        self.assertSetEqual(set(locus_list.keys()), fields)

        self.login_staff_user()
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        locus_lists_dict = response.json()['locusListsByGuid']
        self.assertSetEqual(set(locus_lists_dict.keys()), {LOCUS_LIST_GUID, 'LL00005_retina_proteome'}) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:22,代码来源:locus_list_api_2_3_tests.py

示例2: test_public_locus_list_info

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_public_locus_list_info(self):
        url = reverse(locus_list_info, args=[LOCUS_LIST_GUID])
        self.check_require_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        response_json = response.json()
        locus_lists_dict = response_json['locusListsByGuid']
        self.assertListEqual(list(locus_lists_dict.keys()), [LOCUS_LIST_GUID])

        locus_list = locus_lists_dict[LOCUS_LIST_GUID]
        self.assertSetEqual(set(locus_list.keys()), LOCUS_LIST_DETAIL_FIELDS)
        self.assertSetEqual(
            {item['geneId'] for item in locus_list['items'] if item.get('geneId')},
            set(response_json['genesById'].keys())
        ) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:19,代码来源:locus_list_api_2_3_tests.py

示例3: test_add_and_remove_project_locus_lists

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_add_and_remove_project_locus_lists(self):
        existing_guid = 'LL00005_retina_proteome'

        # add a locus list
        url = reverse(add_project_locus_lists, args=[PROJECT_GUID])
        self.check_manager_login(url)

        response = self.client.post(url, content_type='application/json', data=json.dumps({'locusListGuids': [LOCUS_LIST_GUID]}))
        self.assertEqual(response.status_code, 200)
        self.assertListEqual(response.json()['locusListGuids'], [LOCUS_LIST_GUID, existing_guid])
        ll_projects = LocusList.objects.get(guid=LOCUS_LIST_GUID).projects.all()
        self.assertEqual(ll_projects.count(), 2)
        self.assertTrue(PROJECT_GUID in {p.guid for p in ll_projects})

        # remove a locus list
        url = reverse(delete_project_locus_lists, args=[PROJECT_GUID])
        response = self.client.post(url, content_type='application/json', data=json.dumps({'locusListGuids': [LOCUS_LIST_GUID]}))
        self.assertEqual(response.status_code, 200)
        self.assertListEqual(response.json()['locusListGuids'], [existing_guid])
        ll_projects = LocusList.objects.get(guid=LOCUS_LIST_GUID).projects.all()
        self.assertEqual(ll_projects.count(), 1)
        self.assertFalse(PROJECT_GUID in {p.guid for p in ll_projects}) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:24,代码来源:locus_list_api_2_3_tests.py

示例4: test_query_all_project_families_variants

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_query_all_project_families_variants(self, mock_get_variants):
        url = reverse(query_variants_handler, args=['abc'])
        self.check_collaborator_login(url, request_data={'projectGuids': ['R0003_test']})
        url = reverse(query_variants_handler, args=[SEARCH_HASH])

        mock_get_variants.side_effect = _get_es_variants

        response = self.client.post(url, content_type='application/json', data=json.dumps({
            'projectGuids': ['R0003_test'], 'search': SEARCH
        }))
        self.assertEqual(response.status_code, 200)
        response_json = response.json()
        self.assertDictEqual(response_json['search'], {
            'search': SEARCH,
            'projectFamilies': [{'projectGuid': 'R0003_test', 'familyGuids': ['F000011_11', 'F000012_12']}],
            'totalResults': 3,
        }) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:19,代码来源:variant_search_api_2_3_tests.py

示例5: test_get_all_collaborators

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_get_all_collaborators(self):
        url = reverse(get_all_collaborators)
        self.check_require_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertListEqual(list(response.json().keys()), [])

        self.login_collaborator()
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertSetEqual(set(response.json().keys()), {'test_user_manager', 'test_user_non_staff'})

        self.login_staff_user()
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertSetEqual(set(response.json().keys()), {
            'test_user_manager', 'test_user_non_staff', 'test_user_no_access', 'test_user'}) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:20,代码来源:users_api_2_3_tests.py

示例6: test_set_password

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_set_password(self):
        username = 'test_new_user'
        user = User.objects.create_user(username)
        password = user.password
        auth_user = auth.get_user(self.client)
        self.assertNotEqual(user, auth_user)

        set_password_url = reverse(set_password, args=[username])
        response = self.client.post(set_password_url, content_type='application/json', data=json.dumps({}))
        self.assertEqual(response.status_code, 400)
        self.assertEqual(response.reason_phrase, 'Password is required')

        response = self.client.post(set_password_url, content_type='application/json', data=json.dumps({
            'password': 'password123', 'firstName': 'Test'}))
        self.assertEqual(response.status_code, 200)

        user = User.objects.get(username='test_new_user')
        self.assertEqual(user.first_name, 'Test')
        self.assertFalse(user.password == password)

        auth_user = auth.get_user(self.client)
        self.assertEqual(user, auth_user) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:24,代码来源:users_api_2_3_tests.py

示例7: test_update_saved_variant_json

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_update_saved_variant_json(self, mock_get_variants):
        mock_get_variants.side_effect = lambda families, variant_ids: \
            [{'variantId': variant_id, 'familyGuids': [family.guid for family in families]}
             for variant_id in variant_ids]

        url = reverse(update_saved_variant_json, args=['R0001_1kg'])
        self.check_manager_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        self.assertSetEqual(
            set(response.json().keys()),
            {'SV0000002_1248367227_r0390_100', 'SV0000001_2103343353_r0390_100',
            'SV0059957_11562437_f019313_1', 'SV0059956_11560662_f019313_1'}
        ) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:18,代码来源:saved_variant_api_2_3_tests.py

示例8: test_delete_families_handler

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_delete_families_handler(self):
        url = reverse(delete_families_handler, args=[PROJECT_GUID])
        self.check_staff_login(url)

        # send request with a "families" attribute to provide a list of families
        req_values = {
            'families': [
                {'familyGuid': FAMILY_GUID},
                {'familyGuid': FAMILY_GUID2}
            ]
        }
        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps(req_values))
        self.assertEqual(response.status_code, 200)
        response_json = response.json()
        self.assertSetEqual(set(response_json.keys()), {'individualsByGuid', 'familiesByGuid'})
        self.assertIsNone(response_json['familiesByGuid'][FAMILY_GUID])
        self.assertIsNone(response_json['familiesByGuid'][FAMILY_GUID2])

        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps({'families': None}))
        self.assertEqual(response.status_code, 400) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:24,代码来源:family_api_2_3_tests.py

示例9: test_success_story

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_success_story(self):
        url = reverse(success_story, args=['all'])
        self.check_staff_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        response_json = response.json()
        self.assertListEqual(response_json.keys(), ['rows'])

        self.assertEqual(len(response_json['rows']), 2)
        self.assertDictEqual(response_json['rows'][1], EXPECTED_SUCCESS_STORY)

        url = reverse(success_story, args=['A,T'])

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        response_json = response.json()
        self.assertListEqual(response_json.keys(), ['rows'])

        self.assertEqual(len(response_json['rows']), 1)
        self.assertDictEqual(response_json['rows'][0], EXPECTED_SUCCESS_STORY) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:23,代码来源:staff_api_tests.py

示例10: test_saved_variants_page

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_saved_variants_page(self):
        url = reverse(saved_variants_page, args=['Tier 1 - Novel gene and phenotype'])
        self.check_staff_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 400)
        self.assertEqual(response.json()['message'], 'Select a gene to filter variants')

        response = self.client.get('{}?gene=ENSG00000135953'.format(url))
        self.assertEqual(response.status_code, 200)
        response_json = response.json()
        self.assertSetEqual(set(response_json.keys()), {
            'projectsByGuid', 'locusListsByGuid', 'savedVariantsByGuid', 'variantFunctionalDataByGuid', 'genesById',
            'variantNotesByGuid', 'individualsByGuid', 'variantTagsByGuid', 'familiesByGuid'})
        expected_variant_guids = {
            'SV0000001_2103343353_r0390_100', 'SV0000007_prefix_19107_DEL_r00', 'SV0000006_1248367227_r0003_tes'}
        self.assertSetEqual(set(response_json['savedVariantsByGuid'].keys()), expected_variant_guids)

        all_tag_url = reverse(saved_variants_page, args=['ALL'])
        response = self.client.get('{}?gene=ENSG00000135953'.format(all_tag_url))
        self.assertEqual(response.status_code, 200)
        expected_variant_guids.add('SV0000002_1248367227_r0390_100')
        self.assertSetEqual(set(response.json()['savedVariantsByGuid'].keys()), expected_variant_guids) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:25,代码来源:staff_api_tests.py

示例11: test_empty_project_page_data

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_empty_project_page_data(self):
        url = reverse(project_page_data, args=[EMPTY_PROJECT_GUID])
        self.check_collaborator_login(url)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        response_json = response.json()
        self.assertSetEqual(
            set(response_json.keys()),
            {'projectsByGuid', 'familiesByGuid', 'individualsByGuid', 'samplesByGuid', 'locusListsByGuid',
             'analysisGroupsByGuid', 'genesById', 'mmeSubmissionsByGuid', 'igvSamplesByGuid'}
        )
        self.assertListEqual(list(response_json['projectsByGuid'].keys()), [EMPTY_PROJECT_GUID])
        self.assertDictEqual(response_json['familiesByGuid'], {})
        self.assertDictEqual(response_json['individualsByGuid'], {})
        self.assertDictEqual(response_json['samplesByGuid'], {})
        self.assertDictEqual(response_json['analysisGroupsByGuid'], {})
        self.assertDictEqual(response_json['genesById'], {})
        self.assertDictEqual(response_json['mmeSubmissionsByGuid'], {})
        self.assertDictEqual(response_json['locusListsByGuid'], {}) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:23,代码来源:project_api_2_3_tests.py

示例12: test_proxy_google_to_igv

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_proxy_google_to_igv(self, mock_subprocess):
        mock_subprocess.return_value.stdout = STREAMING_READS_CONTENT

        url = reverse(fetch_igv_track, args=['R0001_1kg', 'gs://project_A/sample_1.bam.bai'])
        self.check_collaborator_login(url)
        response = self.client.get(url, HTTP_RANGE='bytes=100-200')
        self.assertEqual(response.status_code, 206)
        self.assertListEqual([val.decode('utf-8') for val in response.streaming_content], STREAMING_READS_CONTENT)
        mock_subprocess.assert_called_with(
            'gsutil cat -r 100-200 gs://project_A/sample_1.bai',
            stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)

        url = reverse(fetch_igv_track, args=['R0001_1kg', 'gs://fc-secure-project_A/sample_1.cram.gz'])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertListEqual([val.decode('utf-8') for val in response.streaming_content], STREAMING_READS_CONTENT)
        mock_subprocess.assert_called_with(
            'gsutil -u anvil-datastorage cat gs://fc-secure-project_A/sample_1.cram.gz | gunzip -c -q - ',
            stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:21,代码来源:igv_api_2_3_tests.py

示例13: test_proxy_local_to_igv

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_proxy_local_to_igv(self, mock_open):
        mock_file = mock_open.return_value.__enter__.return_value
        mock_file.__iter__.return_value = STREAMING_READS_CONTENT
        mock_file.tell.side_effect = [0, 100, 200]

        url = reverse(fetch_igv_track, args=['R0001_1kg', '/project_A/sample_1.bam.bai'])
        self.check_collaborator_login(url)
        response = self.client.get(url, HTTP_RANGE='bytes=100-200')
        self.assertEqual(response.status_code, 206)
        self.assertListEqual([val.decode('utf-8') for val in response.streaming_content], STREAMING_READS_CONTENT[:2])
        mock_file.seek.assert_called_with(100)

        # test no byte range
        mock_file.reset_mock()
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertListEqual([val.decode('utf-8') for val in response.streaming_content], STREAMING_READS_CONTENT)
        mock_file.seek.assert_not_called() 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:20,代码来源:igv_api_2_3_tests.py

示例14: test_save_internal_case_review_notes

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_save_internal_case_review_notes(self):
        url = reverse(save_internal_case_review_notes, args=[FAMILY_GUID])
        self.check_staff_login(url)

        # send request with a "value" attribute
        req_values = {
            'value': 'some case review notes'
        }
        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps(req_values))
        self.assertEqual(response.status_code, 200)
        response_json = response.json()

        self.assertListEqual(list(response_json.keys()), [FAMILY_GUID])
        self.assertEqual(response_json[FAMILY_GUID]['familyGuid'], FAMILY_GUID)
        self.assertEqual(response_json[FAMILY_GUID]['internalCaseReviewNotes'], req_values['value'])

        # send request with a invalid "value" attribute
        req_values = {
            'valueX': 'some case review notes'
        }
        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps(req_values))
        self.assertEqual(response.status_code, 500) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:26,代码来源:case_review_api_2_3_tests.py

示例15: test_save_internal_case_review_summary

# 需要导入模块: from django.urls import base [as 别名]
# 或者: from django.urls.base import reverse [as 别名]
def test_save_internal_case_review_summary(self):
        url = reverse(save_internal_case_review_summary, args=[FAMILY_GUID])
        self.check_staff_login(url)

        # send request with a "value" attribute
        req_values = {
            'value': 'some case review notes'
        }
        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps(req_values))
        self.assertEqual(response.status_code, 200)
        response_json = response.json()

        self.assertListEqual(list(response_json.keys()), [FAMILY_GUID])
        self.assertEqual(response_json[FAMILY_GUID]['familyGuid'], FAMILY_GUID)
        self.assertEqual(response_json[FAMILY_GUID]['internalCaseReviewSummary'], req_values['value'])
        # send request with a "value" attribute
        req_values = {
            'valueX': 'some case review notes'
        }
        response = self.client.post(url, content_type='application/json',
                                    data=json.dumps(req_values))
        self.assertEqual(response.status_code, 500) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:25,代码来源:case_review_api_2_3_tests.py


注:本文中的django.urls.base.reverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。