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


Python status.HTTP_302_FOUND属性代码示例

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


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

示例1: test_request_token_with_post_method_and_access_key_and_signdata_and_no_login

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_request_token_with_post_method_and_access_key_and_signdata_and_no_login(self):
        url = reverse_lazy('cas_app:cas-request-token')
        serializer = TimedSerializer(self.secret_key)
        data = serializer.dumps({'redirect_to': self.redirect_to})
        data_extra = {
            'HTTP_X_SERVICES_PUBLIC_KEY': self.access_key,
        }
        response = self.client.post(url, data, content_type='application/json', **data_extra)
        response_data = serializer.loads(response.content)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(self.cas_consumer.cas_tokens.count(), 1)
        self.assertIn('request_token', response_data)

        request_token = response_data['request_token']

        url = reverse_lazy('cas_app:cas-user-authentication')
        response = self.client.get(url, data={
            'request_token': request_token,
        })

        self.assertEqual(response.status_code, status.HTTP_302_FOUND)

        print response 
开发者ID:forcemain,项目名称:notes,代码行数:26,代码来源:test_auth.py

示例2: test_google_sheet_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_google_sheet_upload(self):
        """Test the Google Sheet upload."""
        # Get the regular form
        resp = self.get_response('dataops:googlesheetupload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filename = os.path.join(settings.ONTASK_FIXTURE_DIR, 'simple.csv')
        resp = self.get_response(
            'dataops:googlesheetupload_start',
            method='POST',
            req_params={
                'google_url': 'file://' + filename,
                'skip_lines_at_top': -1,
                'skip_lines_at_bottom': 0})
        self.assertNotEqual(resp.status_code, status.HTTP_302_FOUND)
        resp = self.get_response(
            'dataops:googlesheetupload_start',
            method='POST',
            req_params={
                'google_url': 'file://' + filename,
                'skip_lines_at_top': 0,
                'skip_lines_at_bottom': -1})
        self.assertNotEqual(resp.status_code, status.HTTP_302_FOUND) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:test_forms.py

示例3: test_csv_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_csv_upload(self):
        """Test the CSV upload."""
        # Get the regular form
        resp = self.get_response('dataops:csvupload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filename = os.path.join(settings.ONTASK_FIXTURE_DIR, 'simple.csv')
        with open(filename) as fp:
            resp = self.get_response(
                'dataops:csvupload_start',
                method='POST',
                req_params={
                    'data_file': fp,
                    'skip_lines_at_top': 0,
                    'skip_lines_at_bottom': 0})
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('dataops:upload_s2')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:20,代码来源:test_upload_logic.py

示例4: test_excel_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_excel_upload(self):
        """Test the excel upload."""
        # Get the regular form
        resp = self.get_response('dataops:excelupload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filename = os.path.join(
            settings.ONTASK_FIXTURE_DIR,
            'excel_upload.xlsx')
        with open(filename, 'rb') as fp:
            resp = self.get_response(
                'dataops:excelupload_start',
                method='POST',
                req_params={'data_file': fp, 'sheet': 'results'})
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('dataops:upload_s2')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:19,代码来源:test_upload_logic.py

示例5: test_google_sheet_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_google_sheet_upload(self):
        """Test the Google Sheet upload."""
        # Get the regular form
        resp = self.get_response('dataops:googlesheetupload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filename = os.path.join(settings.ONTASK_FIXTURE_DIR, 'simple.csv')
        resp = self.get_response(
            'dataops:googlesheetupload_start',
            method='POST',
            req_params={
                'google_url': 'file://' + filename,
                'skip_lines_at_top': 0,
                'skip_lines_at_bottom': 0})
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('dataops:upload_s2')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:19,代码来源:test_upload_logic.py

示例6: test_s3_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_s3_upload(self):
        """Test the S3 upload."""
        # Get the regular form
        resp = self.get_response('dataops:s3upload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filepath = os.path.join(settings.ONTASK_FIXTURE_DIR, 'simple.csv')
        resp = self.get_response(
            'dataops:s3upload_start',
            method='POST',
            req_params={
                'aws_bucket_name': filepath.split('/')[1],
                'aws_file_key': '/'.join(filepath.split('/')[2:]),
                'skip_lines_at_top': 0,
                'skip_lines_at_bottom': 0,
                'domain': 'file:/'})
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('dataops:upload_s2')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:21,代码来源:test_upload_logic.py

示例7: test_run_canvas_email_action

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_run_canvas_email_action(self):
        """Test Canvas Email action execution."""
        action = self.workflow.actions.get(name='Initial motivation')
        column = action.workflow.columns.get(name='SID')
        resp = self.get_response('action:run', url_params={'pk': action.id})
        self.assertTrue(status.is_success(resp.status_code))

        # POST -> redirect to item filter
        resp = self.get_response(
            'action:run',
            url_params={'pk': action.id},
            method='POST',
            req_params={
                'subject': 'Email subject',
                'item_column': column.pk,
                'target_url': 'Server one',
            },
            session_payload={
                'item_column': column.pk,
                'action_id': action.id,
                'target_url': 'Server one',
                'prev_url': reverse('action:run', kwargs={'pk': action.id}),
                'post_url': reverse('action:run_done'),
            })
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:27,代码来源:test_views_run.py

示例8: assertConfirmationLinkRedirect

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def assertConfirmationLinkRedirect(self, confirmation_link):
        response = self.client.get(confirmation_link)
        self.assertResponse(response, status.HTTP_406_NOT_ACCEPTABLE)
        response = self.client.get(confirmation_link, HTTP_ACCEPT='text/html')
        self.assertResponse(response, status.HTTP_302_FOUND)
        self.assertNoEmailSent() 
开发者ID:desec-io,项目名称:desec-stack,代码行数:8,代码来源:test_user_management.py

示例9: test_group_image_redirect

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_group_image_redirect(self):
        # NOT logged in (as it needs to work in emails)
        photo_file = os.path.join(os.path.dirname(__file__), './photo.jpg')
        group = GroupFactory(photo=photo_file, members=[self.member])
        response = self.client.get('/api/groups-info/{}/photo/'.format(group.id))
        self.assertEqual(response.status_code, status.HTTP_302_FOUND)
        self.assertEqual(response.url, group.photo.url) 
开发者ID:yunity,项目名称:karrot-backend,代码行数:9,代码来源:test_api.py

示例10: test_offer_image_redirect

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_offer_image_redirect(self):
        # NOT logged in (as it needs to work in emails)
        response = self.client.get('/api/offers/{}/image/'.format(self.offer.id))
        self.assertEqual(response.status_code, status.HTTP_302_FOUND)
        self.assertEqual(response.url, self.offer.images.first().image.url) 
开发者ID:yunity,项目名称:karrot-backend,代码行数:7,代码来源:test_api.py

示例11: test_home_page_exists

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_home_page_exists(self):
        url = reverse('home')
        r = self.client.get(url)
        self.assertEqual(r.status_code, status.HTTP_302_FOUND) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:6,代码来源:tests.py

示例12: test_row_edit

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_row_edit(self):
        """Test the view to filter items."""
        # Row edit (GET)
        resp = self.get_response(
            'dataops:rowupdate',
            req_params={'k': 'key', 'v': '8'})
        self.assertTrue(status.is_success(resp.status_code))
        self.assertTrue('Edit learner data' in str(resp.content))

        # Get the GET URL with the paramegters
        request = self.factory.get(
            reverse('dataops:rowupdate'),
            {'k': 'key', 'v': '8'})

        request = self.factory.post(
            request.get_full_path(),
            {
                '___ontask___upload_0': '8',
                '___ontask___upload_1': 'NEW TEXT 1',
                '___ontask___upload_2': 'NEW TEXT 2',
                '___ontask___upload_3': '111',
                '___ontask___upload_4': '222',
                '___ontask___upload_5': 'on',
                '___ontask___upload_6': '',
                '___ontask___upload_7': '06/07/2019 19:32',
                '___ontask___upload_8': '06/05/2019 19:23'}
        )
        request = self.add_middleware(request)
        resp = views.row_update(request)
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)

        row_val = sql.get_row(
            self.workflow.get_data_frame_table_name(),
            key_name='key',
            key_value=8)

        self.assertEqual(row_val['text1'], 'NEW TEXT 1')
        self.assertEqual(row_val['text2'], 'NEW TEXT 2')
        self.assertEqual(row_val['double1'], 111)
        self.assertEqual(row_val['double2'], 222) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:42,代码来源:test_view_row.py

示例13: test_csv_upload

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_csv_upload(self):
        """Test the CSV upload."""
        # Get the regular form
        resp = self.get_response('dataops:csvupload_start')
        self.assertTrue(status.is_success(resp.status_code))

        # POST the data
        filename = os.path.join(settings.ONTASK_FIXTURE_DIR, 'simple.csv')
        with open(filename) as fp:
            resp = self.get_response(
                'dataops:csvupload_start',
                method='POST',
                req_params={
                    'data_file': fp,
                    'skip_lines_at_top': -1,
                    'skip_lines_at_bottom': 0})
            self.assertNotEqual(resp.status_code, status.HTTP_302_FOUND)

            resp = self.get_response(
                'dataops:csvupload_start',
                method='POST',
                req_params={
                    'data_file': fp,
                    'skip_lines_at_top': 0,
                    'skip_lines_at_bottom': -1})
            self.assertNotEqual(resp.status_code, status.HTTP_302_FOUND) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:28,代码来源:test_forms.py

示例14: test_sql_run

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_sql_run(self):
        """Execute the RUN step."""

        sql_conn = models.SQLConnection.objects.get(pk=1)
        self.assertIsNotNone(sql_conn)

        # Modify the item so that it is able to access the DB
        sql_conn.conn_type = 'postgresql'
        sql_conn.db_name = settings.DATABASE_URL['NAME']
        sql_conn.db_user = settings.DATABASE_URL['USER']
        sql_conn.db_password = settings.DATABASE_URL['PASSWORD']
        sql_conn.db_port = settings.DATABASE_URL['PORT']
        sql_conn.db_host = settings.DATABASE_URL['HOST']
        sql_conn.db_table = '__ONTASK_WORKFLOW_TABLE_1'
        sql_conn.save()

        # Load the first step for the sql upload form (GET)
        resp = self.get_response(
            'dataops:sqlupload_start',
            {'pk': sql_conn.id})
        self.assertTrue(status.is_success(resp.status_code))
        self.assertIn('Establish a SQL connection', str(resp.content))

        # Load the first step for the sql upload form (POST)
        resp = self.get_response(
            'dataops:sqlupload_start',
            {'pk': sql_conn.id},
            method='POST',
            req_params={'db_password': 'boguspwd'})
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('dataops:upload_s2')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:33,代码来源:test_sqlconn.py

示例15: test_run_action_item_filter

# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import HTTP_302_FOUND [as 别名]
def test_run_action_item_filter(self):
        """Test the view to filter items."""
        action = self.workflow.actions.get(name='Midterm comments')
        column = action.workflow.columns.get(name='email')
        payload = {
            'item_column': column.pk,
            'action_id': action.id,
            'button_label': 'Send',
            'valuerange': 2,
            'step': 2,
            'prev_url': reverse('action:run', kwargs={'pk': action.id}),
            'post_url': reverse('action:run_done')}
        resp = self.get_response(
            'action:item_filter',
            session_payload=payload)
        self.assertTrue(status.is_success(resp.status_code))

        # POST
        resp = self.get_response(
            'action:item_filter',
            method='POST',
            req_params={
                'exclude_values': ['ctfh9946@bogus.com'],
            },
            session_payload=payload)
        self.assertEqual(resp.status_code, status.HTTP_302_FOUND)
        self.assertEqual(resp.url, reverse('action:run_done')) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:29,代码来源:test_views_run.py


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