本文整理汇总了Python中util.rest.get_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_url函数的具体用法?Python get_url怎么用?Python get_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_missing
def test_missing(self):
"""Tests calling the source files view with an invalid id or file name."""
url = rest_util.get_url('/sources/12345/')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, response.content)
url = rest_util.get_url('/sources/missing_file.txt/')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:10,代码来源:test_views.py
示例2: test_negative_time_range
def test_negative_time_range(self):
"""Tests calling the source files view with a negative time range."""
url = rest_util.get_url('/sources/?started=1970-01-02T00:00:00Z&ended=1970-01-01T00:00:00')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例3: test_warnings
def test_warnings(self):
"""Tests validating a new workspace where the broker type is changed."""
json_config = {
'broker': {
'type': 'host',
'host_path': '/host/path',
},
}
storage_test_utils.create_workspace(name='ws-test', json_config=json_config)
json_data = {
'name': 'ws-test',
'json_config': {
'broker': {
'type': 'nfs',
'nfs_path': 'host:/dir',
},
},
}
url = rest_util.get_url('/workspaces/validation/')
response = self.client.generic('POST', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
results = json.loads(response.content)
self.assertEqual(len(results['warnings']), 1)
self.assertEqual(results['warnings'][0]['id'], 'broker_type')
开发者ID:ngageoint,项目名称:scale,代码行数:28,代码来源:test_views.py
示例4: test_edit_config
def test_edit_config(self):
"""Tests editing the configuration of a workspace"""
config = {
'version': '1.0',
'broker': {
'type': 'nfs',
'nfs_path': 'host:/dir',
},
}
json_data = {
'json_config': config,
}
url = rest_util.get_url('/workspaces/%d/' % self.workspace.id)
response = self.client.generic('PATCH', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
result = json.loads(response.content)
self.assertEqual(result['id'], self.workspace.id)
self.assertEqual(result['title'], self.workspace.title)
self.assertDictEqual(result['json_config'], config)
workspace = Workspace.objects.get(pk=self.workspace.id)
self.assertEqual(workspace.title, self.workspace.title)
self.assertDictEqual(workspace.json_config, config)
开发者ID:ngageoint,项目名称:scale,代码行数:27,代码来源:test_views.py
示例5: test_edit_simple
def test_edit_simple(self):
"""Tests editing only the basic attributes of a workspace"""
json_data = {
'title': 'Title EDIT',
'description': 'Description EDIT',
'is_active': False,
}
url = rest_util.get_url('/workspaces/%d/' % self.workspace.id)
response = self.client.generic('PATCH', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
result = json.loads(response.content)
self.assertTrue(isinstance(result, dict), 'result must be a dictionary')
self.assertEqual(result['id'], self.workspace.id)
self.assertEqual(result['title'], 'Title EDIT')
self.assertEqual(result['description'], 'Description EDIT')
self.assertDictEqual(result['json_config'], self.workspace.json_config)
self.assertFalse(result['is_active'])
workspace = Workspace.objects.get(pk=self.workspace.id)
self.assertEqual(workspace.title, 'Title EDIT')
self.assertEqual(workspace.description, 'Description EDIT')
self.assertFalse(result['is_active'])
开发者ID:ngageoint,项目名称:scale,代码行数:25,代码来源:test_views.py
示例6: test_successful
def test_successful(self):
"""Tests calling the create Workspace view successfully."""
json_data = {
'name': 'ws-name',
'title': 'Workspace Title',
'description': 'Workspace description',
'base_url': 'http://host/my/path/',
'is_active': False,
'json_config': {
'broker': {
'type': 'host',
'host_path': '/host/path',
},
},
}
url = rest_util.get_url('/workspaces/')
response = self.client.generic('POST', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.content)
workspaces = Workspace.objects.filter(name='ws-name')
self.assertEqual(len(workspaces), 1)
result = json.loads(response.content)
self.assertEqual(result['title'], workspaces[0].title)
self.assertEqual(result['description'], workspaces[0].description)
self.assertDictEqual(result['json_config'], workspaces[0].json_config)
self.assertEqual(result['base_url'], workspaces[0].base_url)
self.assertEqual(result['is_active'], workspaces[0].is_active)
self.assertFalse(workspaces[0].is_active)
开发者ID:ngageoint,项目名称:scale,代码行数:31,代码来源:test_views.py
示例7: test_max_duration
def test_max_duration(self):
"""Tests calling the job load view with time values that define a range greater than 31 days"""
url = rest_util.get_url("/load/?started=2015-01-01T00:00:00Z&ended=2015-02-02T00:00:00Z")
response = self.client.generic("GET", url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例8: test_get_error_not_found
def test_get_error_not_found(self):
"""Test calling the Get Error method with a bad error id."""
url = rest_util.get_url('/errors/9999/')
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例9: test_not_found
def test_not_found(self):
"""Tests successfully calling the get batch details view with a batch id that does not exist."""
url = rest_util.get_url('/batches/100/')
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例10: test_invalid_ended
def test_invalid_ended(self):
"""Tests calling the source file updates view when the ended parameter is invalid."""
url = rest_util.get_url('/sources/updates/?started=1970-01-01T00:00:00Z&ended=hello')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例11: test_invalid_started
def test_invalid_started(self):
"""Tests calling the product files view when the started parameter is invalid."""
url = rest_util.get_url('/products/?started=hello')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例12: test_create
def test_create(self):
"""Tests creating a new batch."""
json_data = {
'recipe_type_id': self.recipe_type1.id,
'title': 'batch-title-test',
'description': 'batch-description-test',
'definition': {
'version': '1.0',
'all_jobs': True,
},
}
url = rest_util.get_url('/batches/')
response = self.client.generic('POST', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.content)
batch = Batch.objects.filter(title='batch-title-test').first()
result = json.loads(response.content)
self.assertEqual(result['id'], batch.id)
self.assertEqual(result['title'], 'batch-title-test')
self.assertEqual(result['description'], 'batch-description-test')
self.assertEqual(result['recipe_type']['id'], self.recipe_type1.id)
self.assertIsNotNone(result['event'])
self.assertIsNotNone(result['creator_job'])
self.assertIsNotNone(result['definition'])
开发者ID:ngageoint,项目名称:scale,代码行数:26,代码来源:test_views.py
示例13: test_missing_tz_ended
def test_missing_tz_ended(self):
"""Tests calling the source files view when the ended parameter is missing timezone."""
url = rest_util.get_url('/sources/?started=1970-01-01T00:00:00Z&ended=1970-01-02T00:00:00')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:7,代码来源:test_views.py
示例14: test_bad_trigger_config
def test_bad_trigger_config(self):
"""Tests validating a new recipe type with an invalid trigger rule configuration."""
json_data = {
'name': 'recipe-type-post-test',
'version': '1.0.0',
'description': 'This is a test.',
'definition': {
'version': '1.0',
'input_data': [{
'name': 'input_file',
'type': 'file',
'media_types': ['image/x-hdf5-image'],
}],
'jobs': [],
},
'trigger_rule': {
'type': 'PARSE',
'configuration': {
'BAD': '1.0',
}
}
}
url = rest_util.get_url('/recipe-types/validation/')
response = self.client.generic('POST', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:27,代码来源:test_views.py
示例15: test_edit_definition_and_trigger_rule
def test_edit_definition_and_trigger_rule(self):
"""Tests editing the recipe type definition and trigger rule together"""
definition = self.definition.copy()
definition['input_data'] = [{
'name': 'input_file',
'type': 'file',
'media_types': ['text/plain'],
}]
trigger_config = self.trigger_config.copy()
trigger_config['condition']['media_type'] = 'application/json'
json_data = {
'definition': definition,
'trigger_rule': {
'type': 'PARSE',
'configuration': trigger_config,
}
}
url = rest_util.get_url('/recipe-types/%d/' % self.recipe_type.id)
response = self.client.generic('PATCH', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
result = json.loads(response.content)
self.assertEqual(result['id'], self.recipe_type.id)
self.assertEqual(result['title'], self.recipe_type.title)
self.assertEqual(result['revision_num'], 2)
self.assertEqual(len(result['definition']['input_data']), 1)
self.assertEqual(result['definition']['input_data'][0]['name'], 'input_file')
self.assertEqual(result['trigger_rule']['configuration']['condition']['media_type'], 'application/json')
self.assertNotEqual(result['trigger_rule']['id'], self.trigger_rule.id)
开发者ID:ngageoint,项目名称:scale,代码行数:31,代码来源:test_views.py
示例16: test_create
def test_create(self):
"""Tests creating a new recipe type."""
json_data = {
'name': 'recipe-type-post-test',
'version': '1.0.0',
'title': 'Recipe Type Post Test',
'description': 'This is a test.',
'definition': {
'version': '1.0',
'input_data': [{
'name': 'input_file',
'type': 'file',
'media_types': ['image/x-hdf5-image'],
}],
'jobs': [],
}
}
url = rest_util.get_url('/recipe-types/')
response = self.client.generic('POST', url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.content)
recipe_type = RecipeType.objects.filter(name='recipe-type-post-test').first()
results = json.loads(response.content)
self.assertEqual(results['id'], recipe_type.id)
self.assertIsNone(results['trigger_rule'])
开发者ID:ngageoint,项目名称:scale,代码行数:27,代码来源:test_views.py
示例17: test_nodes_view
def test_nodes_view(self):
""" test the REST call to retrieve an empty list of nodes"""
url = rest_util.get_url('/nodes/')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
results = json.loads(response.content)
self.assertEqual(len(results['results']), 0)
开发者ID:ngageoint,项目名称:scale,代码行数:8,代码来源:test_views.py
示例18: test_update_node_no_fields
def test_update_node_no_fields(self):
"""Test calling the Update Node method with no fields."""
json_data = {}
url = rest_util.get_url('/nodes/%d/' % self.node2.id)
response = self.client.patch(url, json.dumps(json_data), 'application/json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.content)
开发者ID:ngageoint,项目名称:scale,代码行数:8,代码来源:test_views.py
示例19: test_list_all
def test_list_all(self):
"""Tests getting a list of recipe types."""
url = rest_util.get_url('/recipe-types/')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
results = json.loads(response.content)
self.assertEqual(len(results['results']), 2)
开发者ID:ngageoint,项目名称:scale,代码行数:8,代码来源:test_views.py
示例20: test_success
def test_success(self):
"""Test getting overall version/build information successfully"""
url = rest_util.get_url('/version/')
response = self.client.generic('GET', url)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)
result = json.loads(response.content)
self.assertIsNotNone(result['version'])
开发者ID:ngageoint,项目名称:scale,代码行数:8,代码来源:test_views.py
注:本文中的util.rest.get_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论