當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。