本文整理汇总了Python中rest_framework.status.is_success方法的典型用法代码示例。如果您正苦于以下问题:Python status.is_success方法的具体用法?Python status.is_success怎么用?Python status.is_success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rest_framework.status
的用法示例。
在下文中一共展示了status.is_success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _check_filter
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def _check_filter(
self, query_args, expected, expected_status_code=status.HTTP_200_OK
):
"""Check that query_args filter to expected queryset."""
request = factory.get("/", query_args, format="json")
force_authenticate(request, self.admin)
response = self.viewset(request)
if status.is_success(response.status_code):
self.assertEqual(len(response.data), len(expected))
self.assertCountEqual(
[item.pk for item in expected], [item["id"] for item in response.data],
)
else:
self.assertEqual(response.status_code, expected_status_code)
response.render()
return response
示例2: test_put_as_fs_invalid_trade
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_put_as_fs_invalid_trade(self):
"""
Test an invalid Credit Trade Comment PUT by a Fuel supplier
(not party to the trade)
"""
c_url = "/api/comments/1"
test_data = {
"comment": "updated comment 1",
"creditTrade": 201,
"privilegedAccess": False
}
response = self.clients['fs_air_liquide'].put(
c_url,
content_type='application/json',
data=json.dumps(test_data)
)
assert status.is_success(response.status_code)
示例3: test_question_add
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_question_add(self):
"""Test adding a question to a survey."""
# Get the survey action
survey = self.workflow.actions.get(action_type=models.Action.SURVEY)
# GET the form
resp = self.get_response(
'column:question_add',
{'pk': survey.id},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
# Create the new question
resp = self.get_response(
'column:question_add',
{'pk': survey.id},
method='POST',
req_params={
'name': 'NEW QUESTION',
'description_text': 'QUESTION DESCRIPTION',
'data_type': 'string',
'position': '0',
'raw_categories': 'A,B,C,D'},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
示例4: test_formula_column_add
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_formula_column_add(self):
"""Test adding a formula column."""
# GET the form
resp = self.get_response('column:formula_column_add', is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
# Create the new question
resp = self.get_response(
'column:formula_column_add',
method='POST',
req_params={
'name': 'FORMULA COLUMN',
'description_text': 'FORMULA COLUMN DESC',
'data_type': 'integer',
'position': '0',
'columns': ['12', '13'],
'op_type': 'sum'},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
df = pandas.load_table(self.workflow.get_data_frame_table_name())
self.assertTrue(
df['FORMULA COLUMN'].equals(df['Q01'] + df['Q02']))
示例5: test_column_clone
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_column_clone(self):
"""Test adding a random column."""
column = self.workflow.columns.get(name='Q01')
resp = self.get_response(
'column:column_clone',
{'pk': column.id},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
# Create the new question
resp = self.get_response(
'column:column_clone',
{'pk': column.id},
method='POST',
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
df = pandas.load_table(self.workflow.get_data_frame_table_name())
self.assertTrue(df['Copy of Q01'].equals(df['Q01']))
示例6: test_column_restrict
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_column_restrict(self):
"""Test Column restriction."""
column = self.workflow.columns.get(name='Gender')
self.assertEqual(column.categories, [])
resp = self.get_response(
'column:column_restrict',
{'pk': column.id},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
resp = self.get_response(
'column:column_restrict',
{'pk': column.id},
method='POST',
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
column.refresh_from_db()
self.assertEqual(set(column.categories), {'female', 'male'})
示例7: test_assign_luser_column
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_assign_luser_column(self):
"""Test assign luser column option."""
column = self.workflow.columns.get(name='email')
self.assertEqual(self.workflow.luser_email_column, None)
resp = self.get_response(
'workflow:assign_luser_column',
{'pk': column.id},
method='POST',
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
column = self.workflow.columns.get(name='email')
self.workflow.refresh_from_db()
self.assertEqual(self.workflow.luser_email_column, column)
self.assertEqual(self.workflow.lusers.count(), self.workflow.nrows)
示例8: test_google_sheet_upload
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [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)
示例9: test_csv_upload
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [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'))
示例10: test_google_sheet_upload
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [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'))
示例11: test_s3_upload
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [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'))
示例12: test_export
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_export(self):
"""Export ask followed by export request."""
resp = self.get_response(
'workflow:export_ask',
{'wid': self.workflow.id})
self.assertTrue(status.is_success(resp.status_code))
req_params = {
'select_{0}'.format(idx): True
for idx in range(self.workflow.actions.count())}
resp = self.get_response(
'workflow:export_ask',
{'wid': self.workflow.id},
method='POST',
req_params=req_params,
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
示例13: test_workflow_update
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_workflow_update(self):
"""Update the name and description of the workflow."""
# Update name and description
resp = self.get_response(
'workflow:update',
{'wid': self.workflow.id},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
resp = self.get_response(
'workflow:update',
{'wid': self.workflow.id},
method='POST',
req_params={
'name': self.workflow.name + '2',
'description_text': 'description'},
is_ajax=True)
self.assertTrue(status.is_success(resp.status_code))
self.workflow.refresh_from_db()
self.assertEqual(self.workflow_name + '2', self.workflow.name)
self.assertEqual(self.workflow.description_text, 'description')
示例14: test_run_zip
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [as 别名]
def test_run_zip(self):
"""Run the zip action."""
# Get the object first
action = self.workflow.actions.get(name='Suggestions about the forum')
column = action.workflow.columns.get(name='SID')
column_fn = action.workflow.columns.get(name='email')
# Request ZIP action execution
resp = self.get_response('action:zip_action', {'pk': action.id})
self.assertTrue(status.is_success(resp.status_code))
# Post the execution request
resp = self.get_response(
'action:zip_action',
{'pk': action.id},
method='POST',
req_params={
'action_id': action.id,
'item_column': column.pk,
'user_fname_column': column_fn.pk,
'confirm_items': False,
'zip_for_moodle': False,
})
self.assertTrue(status.is_success(resp.status_code))
示例15: test_run_canvas_email_action
# 需要导入模块: from rest_framework import status [as 别名]
# 或者: from rest_framework.status import is_success [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)