本文整理汇总了Python中tests.json_response函数的典型用法代码示例。如果您正苦于以下问题:Python json_response函数的具体用法?Python json_response怎么用?Python json_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wiki_page_refresh_by_title
def test_wiki_page_refresh_by_title(self):
self.response.json = json_response(responses['wiki_page']['get'])
wiki_page = self.redmine.wiki_page.get('Foo', project_id=1)
self.assertEqual(wiki_page.title, 'Foo')
self.response.json = json_response({'wiki_page': {'title': 'Bar'}})
wiki_page = wiki_page.refresh()
self.assertEqual(wiki_page.title, 'Bar')
示例2: test_wiki_page_includes
def test_wiki_page_includes(self):
response_includes = responses['wiki_page']['get']
self.response.json = json_response(response_includes)
wiki_page = self.redmine.wiki_page.get('Foo', project_id=1)
response_includes['wiki_page']['attachments'] = responses['attachment']['get']['attachment']
self.response.json = json_response(response_includes)
self.assertIsInstance(wiki_page.attachments, ResourceSet)
示例3: test_saving_existing_resource_updates_it
def test_saving_existing_resource_updates_it(self):
self.response.json = json_response(responses['project']['get'])
project = self.redmine.project.get(1)
project.name = 'Bar'
self.assertEqual(project.save(), True)
self.response.json = json_response({'project': {'id': 1, 'name': 'Bar'}})
project = project.refresh()
self.assertEqual(project.name, 'Bar')
示例4: test_can_refresh_itself
def test_can_refresh_itself(self):
self.response.json = json_response(responses['project']['get'])
project = self.redmine.project.get(1)
self.assertEqual(project.id, 1)
self.assertEqual(project.name, 'Foo')
self.response.json = json_response({'project': {'id': 2, 'name': 'Bar'}})
project = project.refresh()
self.assertEqual(project.id, 2)
self.assertEqual(project.name, 'Bar')
示例5: test_project_includes
def test_project_includes(self):
response_includes = responses['project']['get']
self.response.json = json_response(response_includes)
project = self.redmine.project.get(1)
response_includes['project'].update(responses['issue_category']['filter'])
self.response.json = json_response(response_includes)
self.assertIsInstance(project.issue_categories, ResourceSet)
response_includes['project'].update(responses['tracker']['all'])
self.response.json = json_response(response_includes)
self.assertIsInstance(project.trackers, ResourceSet)
示例6: test_group_includes
def test_group_includes(self):
response_includes = responses['group']['get']
self.response.json = json_response(response_includes)
group = self.redmine.group.get(1)
response_includes['group']['memberships'] = responses['project_membership']['filter']['memberships']
self.response.json = json_response(response_includes)
self.assertIsInstance(group.memberships, ResourceSet)
response_includes['group']['users'] = responses['user']['all']['users']
self.response.json = json_response(response_includes)
self.assertIsInstance(group.users, ResourceSet)
示例7: test_enumeration_filter
def test_enumeration_filter(self):
self.response.json = json_response(responses['enumeration']['filter'])
enumerations = self.redmine.enumeration.filter(resource='time_entry_activities')
self.assertEqual(enumerations[0].id, 1)
self.assertEqual(enumerations[0].name, 'Foo')
self.assertEqual(enumerations[1].id, 2)
self.assertEqual(enumerations[1].name, 'Bar')
示例8: test_time_entry_filter
def test_time_entry_filter(self):
self.response.json = json_response(responses['time_entry']['filter'])
time_entries = self.redmine.time_entry.filter(issue_id=1)
self.assertEqual(time_entries[0].id, 1)
self.assertEqual(time_entries[0].hours, 3)
self.assertEqual(time_entries[1].id, 2)
self.assertEqual(time_entries[1].hours, 4)
示例9: test_time_entry_all
def test_time_entry_all(self):
self.response.json = json_response(responses['time_entry']['all'])
time_entries = self.redmine.time_entry.all()
self.assertEqual(time_entries[0].id, 1)
self.assertEqual(time_entries[0].hours, 3)
self.assertEqual(time_entries[1].id, 2)
self.assertEqual(time_entries[1].hours, 4)
示例10: test_issue_version_can_be_retrieved_via_version_attribute
def test_issue_version_can_be_retrieved_via_version_attribute(self):
from redmine.resources import Version
self.response.json = json_response(
{'issue': {'subject': 'Foo', 'id': 1, 'fixed_version': {'id': 1, 'name': 'Foo'}}}
)
issue = self.redmine.issue.get(1)
self.assertIsInstance(issue.version, Version)
示例11: test_news_all
def test_news_all(self):
self.response.json = json_response(responses['news']['all'])
news = self.redmine.news.all()
self.assertEqual(news[0].id, 1)
self.assertEqual(news[0].title, 'Foo')
self.assertEqual(news[1].id, 2)
self.assertEqual(news[1].title, 'Bar')
示例12: test_version_filter
def test_version_filter(self):
self.response.json = json_response(responses['version']['filter'])
versions = self.redmine.version.filter(project_id=1)
self.assertEqual(versions[0].id, 1)
self.assertEqual(versions[0].name, 'Foo')
self.assertEqual(versions[1].id, 2)
self.assertEqual(versions[1].name, 'Bar')
示例13: test_custom_field_all
def test_custom_field_all(self):
self.response.json = json_response(responses['custom_field']['all'])
fields = self.redmine.custom_field.all()
self.assertEqual(fields[0].id, 1)
self.assertEqual(fields[0].name, 'Foo')
self.assertEqual(fields[1].id, 2)
self.assertEqual(fields[1].name, 'Bar')
示例14: test_dir_returns_resource_attributes
def test_dir_returns_resource_attributes(self):
self.response.json = json_response(responses['issue']['get'])
attributes = dir(self.redmine.issue.get(1))
self.assertIn('id', attributes)
self.assertIn('subject', attributes)
self.assertIn('relations', attributes)
self.assertIn('time_entries', attributes)
示例15: test_project_membership_update
def test_project_membership_update(self):
self.response.json = json_response(responses['project_membership']['get'])
membership = self.redmine.project_membership.get(1)
membership.role_ids = [1, 2]
self.assertEqual(membership.save(), True)
self.assertEqual(membership.roles[0].id, 1)
self.assertEqual(membership.roles[1].id, 2)