本文整理汇总了Python中osc2.remote.Request类的典型用法代码示例。如果您正苦于以下问题:Python Request类的具体用法?Python Request怎么用?Python Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_request4
def test_request4(self):
"""test request validation (incoming + outgoing)"""
Request.SCHEMA = self.fixture_file('request_simple.xsd')
self.assertRaises(etree.DocumentInvalid, Request.find, '456')
req = Request()
req.add_action(type='submit')
req.add_invalid(attr='inv')
# no http request is made because validation fails
self.assertRaises(etree.DocumentInvalid, req.store)
req = Request()
req.add_action(type='submit')
# check that validation is ok
req.validate()
# we get an invalid response
self.assertRaises(etree.DocumentInvalid, req.store)
示例2: test_request18
def test_request18(self):
"""test request diff (returned object should have a write_to method"""
req = Request.find('120703')
f = req.diff()
sio = StringIO()
f.write_to(sio)
self.assertEqual(sio.getvalue(), 'some diff content\n')
示例3: create
def create(cls, renderer, submit, changedevel, role, grouprole, delete,
info):
"""Creates a new request."""
global SHOW_TEMPLATE
request = Request()
message = info.message
if message is None:
message = edit_message()
cls._create_submit_actions(request, submit)
cls._create_changedevel_actions(request, changedevel)
cls._create_role_actions(request, role)
cls._create_grouprole_actions(request, grouprole)
cls._create_delete_actions(request, delete)
request.description = message
request.store()
renderer.render(SHOW_TEMPLATE, request=request)
示例4: test_request1
def test_request1(self):
"""get a request"""
req = Request.find('123')
self.assertTrue(len(req.action[:]) == 2)
self.assertEqual(req.action[0].get('type'), 'submit')
self.assertEqual(req.action[0].source.get('package'), 'abc')
self.assertEqual(req.action[0].source.get('project'), 'xyz')
self.assertEqual(req.action[0].options.sourceupdate, 'cleanup')
self.assertEqual(req.action[0].options.updatelink, '1')
self.assertEqual(req.action[1].get('type'), 'add_role')
self.assertEqual(req.action[1].target.get('project'), 'home:foo')
self.assertEqual(req.action[1].person.get('name'), 'bar')
self.assertEqual(req.action[1].person.get('role'), 'maintainer')
self.assertEqual(req.action[1].group.get('name'), 'groupxyz')
self.assertEqual(req.action[1].group.get('role'), 'reader')
self.assertEqual(req.state.get('name'), 'review')
self.assertEqual(req.state.get('when'), '2010-12-27T01:36:29')
self.assertEqual(req.state.get('who'), 'abc')
self.assertEqual(req.review.get('by_group'), 'group1')
self.assertEqual(req.review.get('state'), 'new')
self.assertEqual(req.review.get('when'), '2010-12-28T00:11:22')
self.assertEqual(req.review.get('who'), 'abc')
self.assertTrue(len(req.history[:]) == 1)
self.assertEqual(req.review.comment, 'review start')
self.assertEqual(req.history[0].get('name'), 'new')
self.assertEqual(req.history[0].get('when'), '2010-12-11T00:00:00')
self.assertEqual(req.history[0].get('who'), 'creator')
示例5: show
def show(cls, renderer, reqid, info):
"""Shows the request specified by reqid."""
global SHOW_TEMPLATE
request = Request.find(reqid)
if info.interactive:
cls.shell(renderer, info.shell_cls, [request], info)
return
renderer.render(SHOW_TEMPLATE, request=request)
if info.diff:
cls.diff(request)
示例6: test_request11
def test_request11(self):
"""test decline request"""
req = Request.find('73270')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'new')
# decline request
req.decline(comment='does not build')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'declined')
self.assertEqual(req.state.comment, 'does not build')
示例7: test_request10
def test_request10(self):
"""test revoke request"""
req = Request.find('73270')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'new')
# revoke request
req.revoke(comment='needs some more work')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'revoked')
self.assertEqual(req.state.comment, 'needs some more work')
示例8: test_request9
def test_request9(self):
"""test accept request"""
req = Request.find('73270')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'new')
# accept request
req.accept(comment='thanks')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'accepted')
self.assertEqual(req.state.comment, 'thanks')
示例9: change_request_state
def change_request_state(cls, renderer, reqid, method, message, info,
supersede_id=None):
"""Changes the state of the request id reqid.
method is the method which is called on the
retrieved request object.
If message is None $EDITOR is opened.
"""
request = Request.find(reqid)
cls._change_request_state(renderer, request, method, message, info,
supersede_id)
示例10: test_request3
def test_request3(self):
"""test request validation (incoming + outgoing)"""
Request.SCHEMA = self.fixture_file('request_simple.xsd')
req = Request.find('456')
req = Request()
req.add_action(type='submit')
req.store()
示例11: test_request19
def test_request19(self):
"""create a request (test None attrib filter in class ElementFactory"""
# nearly identical to test_request2 (except the None's here and there)
req = Request()
action = req.add_action(type='submit', xyz=None)
action.add_source(project='foo', package='bar', rev='12345')
action.add_target(project='foobar', package=None)
options = action.add_options()
options.add_sourceupdate('cleanup', attr=None)
req.description = 'some description'
req.store()
self.assertEqual(req.get('id'), '42')
self.assertTrue(len(req.action) == 1)
self.assertEqual(req.action[0].get('type'), 'submit')
self.assertEqual(req.action[0].source.get('project'), 'foo')
self.assertEqual(req.action[0].source.get('package'), 'bar')
self.assertEqual(req.action[0].source.get('rev'), '12345')
self.assertEqual(req.action[0].target.get('project'), 'foobar')
self.assertIsNone(req.action[0].target.get('package'))
self.assertEqual(req.action[0].options.sourceupdate, 'cleanup')
self.assertIsNone(req.action[0].options.sourceupdate.get('attr'))
self.assertEqual(req.state.get('name'), 'new')
self.assertEqual(req.state.get('who'), 'username')
self.assertEqual(req.state.get('when'), '2011-06-10T14:33:55')
self.assertEqual(req.description, 'some description')
示例12: test_request12
def test_request12(self):
"""test supersede request"""
req = Request.find('73270')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'new')
self.assertTrue(req.state.get('superseded_by') is None)
# supersed request
req.supersede('59130', comment='already accepted')
self.assertEqual(req.get('id'), '73270')
self.assertEqual(req.state.get('name'), 'superseded')
# XXX: or should this be a reference to the request object?
self.assertEqual(req.state.get('superseded_by'), '59130')
self.assertEqual(req.state.comment, 'already accepted')
示例13: add
def add(cls, renderer, reqid, message, info):
"""Adds a new review to a request."""
request = Request.find(reqid)
if message is None:
message = edit_message()
kwargs = {'comment': message, 'by_user': info.user,
'by_group': info.group}
if info.package:
kwargs['by_project'] = info.package[0].project
kwargs['by_package'] = info.package[0].package
elif info.project is not None:
kwargs['by_project'] = info.project
request.add_review(**kwargs)
renderer.render(SHOW_TEMPLATE, request=request)
示例14: change_review_state
def change_review_state(cls, renderer, reqid, method, message, info,
supersede_id=None):
"""Changes the state of a review.
method is the method which is called on the
retrieved request object.
If message is None $EDITOR is opened.
"""
request = Request.find(reqid)
reviews = cls._find_reviews(request, info)
if reviews:
# take the first review
cls._change_review_state(renderer, request, reviews[0], method,
message, info, supersede_id)
示例15: test_request15
def test_request15(self):
"""test supersede review"""
req = Request.find('120704')
self.assertEqual(req.get('id'), '120704')
self.assertEqual(req.state.get('name'), 'review')
self.assertEqual(len(req.review[:]), 3)
review = req.review[2]
self.assertTrue(review.get('state'), 'new')
self.assertTrue(review.get('by_group'), 'autobuild-team')
# supersede review
req.supersede('12345', comment='see rq12345', review=review)
self.assertEqual(req.get('id'), '120704')
self.assertEqual(req.state.get('name'), 'superseded')
self.assertEqual(len(req.review[:]), 3)
self.assertEqual(req.review[2].get('state'), 'superseded')
self.assertEqual(req.review[2].comment, 'see rq12345')