当前位置: 首页>>代码示例>>Python>>正文


Python BuildMaster.match_request方法代码示例

本文整理汇总了Python中bitten.master.BuildMaster.match_request方法的典型用法代码示例。如果您正苦于以下问题:Python BuildMaster.match_request方法的具体用法?Python BuildMaster.match_request怎么用?Python BuildMaster.match_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitten.master.BuildMaster的用法示例。


在下文中一共展示了BuildMaster.match_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_process_build_step_invalid_datetime

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_invalid_datetime(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42, status=Build.IN_PROGRESS)
        build.slave_info[Build.IP_ADDRESS] = '127.0.0.1';
        build.insert()

        inbody = StringIO("""<result step="foo" status="success"
                                     time="sometime tomorrow maybe"
                                     duration="3.45">
</result>""")
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read)

        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPBadRequest')
        except HTTPBadRequest, e:
            self.assertEqual("Invalid ISO date/time 'sometime tomorrow maybe'",
                             e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:32,代码来源:master.py

示例2: test_process_build_step_invalid_xml

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_invalid_xml(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42)
        build.insert()

        inbody = StringIO("""<result></rsleut>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))

        module = BuildMaster(self.env)

        module._start_new_step(build, 'foo').insert()

        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEquals(400, outheaders['Status'])
        self.assertEquals('XML parser error', outbody.getvalue())
开发者ID:kroman0,项目名称:bitten,代码行数:36,代码来源:master.py

示例3: test_cancel_build

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_cancel_build(self):
        config = BuildConfig(self.env, 'test', path='somepath', active=True,
                             recipe='<build></build>')
        config.insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      status=Build.IN_PROGRESS, started=42)
        build.insert()

        outheaders = {}
        outbody = StringIO()
        req = Mock(method='DELETE', base_path='',
                   path_info='/builds/%d' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))

        module = BuildMaster(self.env)
        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(204, outheaders['Status'])
        self.assertEqual('', outbody.getvalue())

        # Make sure the started timestamp has been set
        build = Build.fetch(self.env, build.id)
        self.assertEqual(Build.PENDING, build.status)
        assert not build.started
开发者ID:kroman0,项目名称:bitten,代码行数:33,代码来源:master.py

示例4: test_process_build_step_no_post

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_no_post(self):
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe='<build></build>').insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42)
        build.insert()

        outheaders = {}
        outbody = StringIO()
        req = Mock(method='GET', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))

        module = BuildMaster(self.env)

        module._start_new_step(build, 'foo').insert()

        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(405, outheaders['Status'])
        self.assertEqual('Method GET not allowed', outbody.getvalue())
开发者ID:kroman0,项目名称:bitten,代码行数:30,代码来源:master.py

示例5: test_create_build_protocol_no_version

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_create_build_protocol_no_version(self):
        inheaders = {'Content-Type': 'application/x-bitten+xml'}
        inbody = StringIO("""<slave name="hal">
  <platform>Power Macintosh</platform>
  <os family="posix" version="8.1.0">Darwin</os>
</slave>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='', path_info='/builds',
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   get_header=lambda x: inheaders.get(x), read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))

        module = BuildMaster(self.env)
        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(400, outheaders['Status'])
        self.assertEqual('Master-Slave version mismatch: master=%d, slave=1' \
                                % (PROTOCOL_VERSION,),
                            outbody.getvalue())
开发者ID:kroman0,项目名称:bitten,代码行数:28,代码来源:master.py

示例6: test_process_build_step_invalid_xml

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_invalid_xml(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42)
        build.insert()

        inbody = StringIO("""<result></rsleut>""")
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read)

        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPBadRequest')
        except HTTPBadRequest, e:
            self.assertEqual('XML parser error', e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:27,代码来源:master.py

示例7: test_process_build_step_success_with_log

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_success_with_log(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42, status=Build.IN_PROGRESS)
        build.slave_info[Build.IP_ADDRESS] = '127.0.0.1';
        build.insert()

        inbody = StringIO("""<result step="foo" status="success"
                                     time="2007-04-01T15:30:00.0000"
                                     duration="3.45">
    <log generator="http://bitten.cmlenz.net/tools/python#unittest">
        <message level="info">Doing stuff</message>
        <message level="error">Ouch that hurt</message>
    </log>
</result>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write)
        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected RequestDone')
        except RequestDone:
            self.assertEqual(201, outheaders['Status'])
            self.assertEqual('20', outheaders['Content-Length'])
            self.assertEqual('text/plain', outheaders['Content-Type'])
            self.assertEqual('Build step processed', outbody.getvalue())

            build = Build.fetch(self.env, build.id)
            self.assertEqual(Build.SUCCESS, build.status)
            assert build.stopped
            assert build.stopped > build.started

            steps = list(BuildStep.select(self.env, build.id))
            self.assertEqual(1, len(steps))
            self.assertEqual('foo', steps[0].name)
            self.assertEqual(BuildStep.SUCCESS, steps[0].status)

            logs = list(BuildLog.select(self.env, build=build.id, step='foo'))
            self.assertEqual(1, len(logs))
            self.assertEqual('http://bitten.cmlenz.net/tools/python#unittest',
                             logs[0].generator)
            self.assertEqual(2, len(logs[0].messages))
            self.assertEqual((u'info', u'Doing stuff'), logs[0].messages[0])
            self.assertEqual((u'error', u'Ouch that hurt'), logs[0].messages[1])
开发者ID:blaxter,项目名称:Bitten,代码行数:61,代码来源:master.py

示例8: test_create_build_no_post

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
 def test_create_build_no_post(self):
     req = Mock(method='GET', base_path='', path_info='/builds',
                href=Href('/trac'), remote_addr='127.0.0.1', args={},
                perm=PermissionCache(self.env, 'hal'))
     module = BuildMaster(self.env)
     assert module.match_request(req)
     try:
         module.process_request(req)
         self.fail('Expected HTTPMethodNotAllowed')
     except HTTPMethodNotAllowed, e:
         self.assertEqual('Method not allowed', e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:13,代码来源:master.py

示例9: test_initiate_build_no_such_build

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_initiate_build_no_such_build(self):
        req = Mock(method='GET', base_path='',
                   path_info='/builds/123', href=Href('/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'))

        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPNotFound')
        except HTTPNotFound, e:
            self.assertEqual('No such build', e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:15,代码来源:master.py

示例10: test_process_build_step_failure_continue

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_failure_continue(self):
        recipe = """<build>
  <step id="foo" onerror="continue">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42, status=Build.IN_PROGRESS)
        build.slave_info[Build.TOKEN] = '123';

        build.insert()

        inbody = StringIO("""<result step="foo" status="failure"
                                     time="2007-04-01T15:30:00.0000"
                                     duration="3.45">
</result>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth=123'))
        module = BuildMaster(self.env)

        module._start_new_step(build, 'foo').insert()

        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(201, outheaders['Status'])
        self.assertEqual('20', outheaders['Content-Length'])
        self.assertEqual('text/plain', outheaders['Content-Type'])
        self.assertEqual('Build step processed', outbody.getvalue())

        build = Build.fetch(self.env, build.id)
        self.assertEqual(Build.FAILURE, build.status)
        assert build.stopped
        assert build.stopped > build.started

        steps = list(BuildStep.select(self.env, build.id))
        self.assertEqual(1, len(steps))
        self.assertEqual('foo', steps[0].name)
        self.assertEqual(BuildStep.FAILURE, steps[0].status)
开发者ID:kroman0,项目名称:bitten,代码行数:53,代码来源:master.py

示例11: test_create_build

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_create_build(self):
        BuildConfig(self.env, 'test', path='somepath', active=True).insert()
        platform = TargetPlatform(self.env, config='test', name="Unix")
        platform.rules.append(('family', 'posix'))
        platform.insert()

        self.repos = Mock(
            get_node=lambda path, rev=None: Mock(
                get_entries=lambda: [Mock(), Mock()],
                get_history=lambda: [('somepath', 123, 'edit'),
                                     ('somepath', 121, 'edit'),
                                     ('somepath', 120, 'edit')]
            ),
            get_changeset=lambda rev: Mock(date=to_datetime(42, utc)),
            normalize_path=lambda path: path,
            rev_older_than=lambda rev1, rev2: rev1 < rev2
        )

        inheaders = {'Content-Type': 'application/x-bitten+xml'}
        inbody = StringIO("""<slave name="hal" version="%d">
  <platform>Power Macintosh</platform>
  <os family="posix" version="8.1.0">Darwin</os>
  <package name="java" version="2.4.3"/>
</slave>""" % PROTOCOL_VERSION)
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='', path_info='/builds',
                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   get_header=lambda x: inheaders.get(x), read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))

        module = BuildMaster(self.env)
        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(201, outheaders['Status'])
        self.assertEqual('text/plain', outheaders['Content-Type'])
        location = outheaders['Location']
        mo = re.match('http://example.org/trac/builds/(\d+)', location)
        assert mo, 'Location was %r' % location
        self.assertEqual('Build pending', outbody.getvalue())
        build = Build.fetch(self.env, int(mo.group(1)))
        self.assertEqual(Build.IN_PROGRESS, build.status)
        self.assertEqual('hal', build.slave)
开发者ID:kroman0,项目名称:bitten,代码行数:52,代码来源:master.py

示例12: test_process_build_step_wrong_slave

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_wrong_slave(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42, status=Build.IN_PROGRESS)
        build.slave_info[Build.TOKEN] = '123';
        build.insert()

        inbody = StringIO("""<result step="foo" status="success"
                                     time="2007-04-01T15:30:00.0000"
                                     duration="3.45">
    <log generator="http://bitten.edgewall.org/tools/python#unittest">
        <message level="info">Doing stuff</message>
        <message level="error">Ouch that hurt</message>
    </log>
</result>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write,
                   incookie=Cookie('trac_auth='))
        module = BuildMaster(self.env)

        module._start_new_step(build, 'foo').insert()

        assert module.match_request(req)

        self.assertRaises(RequestDone, module.process_request, req)

        self.assertEqual(409, outheaders['Status'])
        self.assertEqual('Token mismatch (wrong slave): slave=, build=123',
                        outbody.getvalue())

        build = Build.fetch(self.env, build.id)
        self.assertEqual(Build.IN_PROGRESS, build.status)
        assert not build.stopped

        steps = list(BuildStep.select(self.env, build.id))
        self.assertEqual(1, len(steps))
开发者ID:kroman0,项目名称:bitten,代码行数:52,代码来源:master.py

示例13: test_create_build_invalid_xml

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_create_build_invalid_xml(self):
        inheaders = {'Content-Type': 'application/x-bitten+xml'}
        inbody = StringIO('<slave></salve>')
        req = Mock(method='POST', base_path='', path_info='/builds',
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   get_header=lambda x: inheaders.get(x), read=inbody.read)

        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPBadRequest')
        except HTTPBadRequest, e:
            self.assertEqual('XML parser error', e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:17,代码来源:master.py

示例14: test_process_build_step_wrong_slave

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_build_step_wrong_slave(self):
        recipe = """<build>
  <step id="foo">
  </step>
</build>"""
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe=recipe).insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42,
                      started=42, status=Build.IN_PROGRESS)
        build.slave_info[Build.IP_ADDRESS] = '192.168.1.1';
        build.insert()

        inbody = StringIO("""<result step="foo" status="success"
                                     time="2007-04-01T15:30:00.0000"
                                     duration="3.45">
    <log generator="http://bitten.cmlenz.net/tools/python#unittest">
        <message level="info">Doing stuff</message>
        <message level="error">Ouch that hurt</message>
    </log>
</result>""")
        outheaders = {}
        outbody = StringIO()
        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/steps/' % build.id,
                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
                   remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'),
                   read=inbody.read,
                   send_response=lambda x: outheaders.setdefault('Status', x),
                   send_header=lambda x, y: outheaders.setdefault(x, y),
                   write=outbody.write)
        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPForbidden')
        except HTTPForbidden, e:
            self.assertEqual('Build 1 has been invalidated for host 127.0.0.1.', e.detail)

            build = Build.fetch(self.env, build.id)
            self.assertEqual(Build.IN_PROGRESS, build.status)
            assert not build.stopped

            steps = list(BuildStep.select(self.env, build.id))
            self.assertEqual(0, len(steps))
开发者ID:blaxter,项目名称:Bitten,代码行数:47,代码来源:master.py

示例15: test_process_unknown_collection

# 需要导入模块: from bitten.master import BuildMaster [as 别名]
# 或者: from bitten.master.BuildMaster import match_request [as 别名]
    def test_process_unknown_collection(self):
        BuildConfig(self.env, 'test', path='somepath', active=True,
                    recipe='<build></build>').insert()
        build = Build(self.env, 'test', '123', 1, slave='hal', rev_time=42)
        build.insert()

        req = Mock(method='POST', base_path='',
                   path_info='/builds/%d/files/' % build.id,
                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
                   perm=PermissionCache(self.env, 'hal'))

        module = BuildMaster(self.env)
        assert module.match_request(req)
        try:
            module.process_request(req)
            self.fail('Expected HTTPNotFound')
        except HTTPNotFound, e:
            self.assertEqual('No such collection', e.detail)
开发者ID:blaxter,项目名称:Bitten,代码行数:20,代码来源:master.py


注:本文中的bitten.master.BuildMaster.match_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。