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


Python testutil.call函数代码示例

本文整理汇总了Python中turbogears.testutil.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_textfield

def test_textfield():
    """Test form rendering inside a request."""
    #form name is prepended to element ids only when running inside a request.
    class MyField(widgets.WidgetsList):
        blonk = widgets.TextField()
    tf = widgets.ListForm(fields=MyField())

    class MyFieldOverrideName(widgets.WidgetsList):
        blonk = widgets.TextField(name="blink")
    tf2 = widgets.ListForm(fields=MyFieldOverrideName())

    class MyRoot(controllers.RootController):
        [expose()]
        def fields(self):
            return tf.render(format='xhtml')

        [expose()]
        def override(self):
            return tf2.render(format='xhtml')

    root = MyRoot()
    d = call(root.fields)
    assert 'name="blonk"' in d
    assert 'id="form_blonk"' in d

    d = call(root.override)
    assert 'name="blink"' in d
    assert 'id="form_blink"' in d
开发者ID:OnShift,项目名称:turbogears,代码行数:28,代码来源:test_widgets.py

示例2: test_index

 def test_index(self):
     "Test that call_with_request is usable if controller uses redirect"
     try:
         testutil.call(self.root.redirect)
         self.fail("no redirect exception raised")
     except cherrypy.HTTPRedirect, e:
         assert e.status in [302, 303]
         self.assertEquals(1, len(e.urls))
         assert e.urls[0].endswith("foo")
开发者ID:OnShift,项目名称:turbogears,代码行数:9,代码来源:test_testutil.py

示例3: test_job_with_custom_distro_without_optional_attributes_can_be_roundtripped

 def test_job_with_custom_distro_without_optional_attributes_can_be_roundtripped(self):
     complete_job_xml = '''
                 <job>
                     <whiteboard>
                         so pretty
                     </whiteboard>
                     <recipeSet>
                         <recipe>
                             <distro>
                                 <tree url="ftp://dummylab.example.com/distros/MyCustomLinux1.0/Server/i386/os/"/>
                                 <initrd url="pxeboot/initrd"/>
                                 <kernel url="pxeboot/vmlinuz"/>
                                 <arch value="i386"/>
                                 <osversion major="RedHatEnterpriseLinux7"/>
                             </distro>
                             <hostRequires/>
                             <task name="/distribution/check-install"/>
                         </recipe>
                     </recipeSet>
                 </job>
             '''
     xmljob = lxml.etree.fromstring(complete_job_xml)
     job = testutil.call(self.controller.process_xmljob, xmljob, self.user)
     roundtripped_xml = lxml.etree.tostring(job.to_xml(clone=True), pretty_print=True, encoding='utf8')
     self.assertIn('<tree url="ftp://dummylab.example.com/distros/MyCustomLinux1.0/Server/i386/os/"/>', roundtripped_xml)
     self.assertIn('<initrd url="pxeboot/initrd"/>', roundtripped_xml)
     self.assertIn('<kernel url="pxeboot/vmlinuz"/>', roundtripped_xml)
     self.assertIn('<arch value="i386"/>', roundtripped_xml)
     self.assertIn('<osversion major="RedHatEnterpriseLinux7" minor="0"/>', roundtripped_xml)
开发者ID:beaker-project,项目名称:beaker,代码行数:29,代码来源:test_jobs.py

示例4: test_job_xml_can_be_roundtripped

 def test_job_xml_can_be_roundtripped(self):
     # Ideally the logic for parsing job XML into a Job instance would live in model code,
     # so that this test doesn't have to go through the web layer...
     complete_job_xml = pkg_resources.resource_string('bkr.inttest', 'complete-job.xml')
     xmljob = XmlJob(xmltramp.parse(complete_job_xml))
     with session.begin():
         job = testutil.call(self.controller.process_xmljob, xmljob, self.user)
     roundtripped_xml = job.to_xml(clone=True).toprettyxml(indent='    ')
     self.assertMultiLineEqual(roundtripped_xml, complete_job_xml)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:9,代码来源:test_jobs.py

示例5: calldefault

 def calldefault(self,*args,**kwargs):
     import urllib
     args = list(args)
     location = args[0]
     method = args[1]
     parameters=urllib.urlencode(kwargs)
     print parameters 
     url = 'URL: /%s/%s?%s' % (location,method,parameters)
     print url
     return testutil.call(cherrypy.root.default,*args,**kwargs)
开发者ID:mightymau,项目名称:hubspace,代码行数:10,代码来源:test_model.py

示例6: test_complete_job_results

    def test_complete_job_results(self):
        complete_job_xml = pkg_resources.resource_string('bkr.inttest', 'complete-job.xml')
        xmljob = lxml.etree.fromstring(complete_job_xml)
        job = testutil.call(self.controller.process_xmljob, xmljob, self.user)
        session.flush()

        # Complete the job, filling in values to match what's hardcoded in 
        # complete-job-results.xml...
        recipe = job.recipesets[0].recipes[0]
        guestrecipe = recipe.guests[0]
        data_setup.mark_recipe_running(recipe, fqdn=u'system.test-complete-job-results',
                start_time=datetime.datetime(2016, 1, 31, 23, 0, 0),
                install_started=datetime.datetime(2016, 1, 31, 23, 0, 1),
                install_finished=datetime.datetime(2016, 1, 31, 23, 0, 2),
                postinstall_finished=datetime.datetime(2016, 1, 31, 23, 0, 3),
                task_start_time=datetime.datetime(2016, 1, 31, 23, 0, 4))
        data_setup.mark_recipe_complete(guestrecipe, fqdn=u'guest.test-complete-job-results',
                mac_address='ff:ff:ff:00:00:00',
                start_time=datetime.datetime(2016, 1, 31, 23, 30, 0),
                install_started=datetime.datetime(2016, 1, 31, 23, 30, 1),
                install_finished=datetime.datetime(2016, 1, 31, 23, 30, 2),
                postinstall_finished=datetime.datetime(2016, 1, 31, 23, 30, 3),
                finish_time=datetime.datetime(2016, 1, 31, 23, 30, 4))
        data_setup.mark_recipe_complete(recipe, only=True,
                start_time=datetime.datetime(2016, 1, 31, 23, 0, 4),
                finish_time=datetime.datetime(2016, 1, 31, 23, 59, 0))
        recipe.installation.rendered_kickstart.url = u'http://example.com/recipe.ks'
        guestrecipe.installation.rendered_kickstart.url = u'http://example.com/guest.ks'
        session.flush()
        # Hack up the database ids... This will fail if it's flushed, but it's 
        # the easiest way to make them match the expected values.
        job.id = 1
        job.recipesets[0].id = 1
        recipe.id = 1
        guestrecipe.id = 2
        recipe.tasks[0].id = 1
        recipe.tasks[1].id = 2
        guestrecipe.tasks[0].id = 3
        guestrecipe.tasks[0].results[0].id = 1
        recipe.tasks[0].results[0].id = 2
        recipe.tasks[1].results[0].id = 3

        expected_results_xml = pkg_resources.resource_string('bkr.inttest', 'complete-job-results.xml')
        expected_results_xml = expected_results_xml.replace(
                '${BEAKER_SERVER_BASE_URL}', get_server_base())
        actual_results_xml = lxml.etree.tostring(job.to_xml(clone=False),
                pretty_print=True, encoding='utf8')
        self.assertMultiLineEqual(expected_results_xml, actual_results_xml)
开发者ID:beaker-project,项目名称:beaker,代码行数:48,代码来源:test_jobs.py

示例7: test_method

 def test_method(self):
     "the welcome method returns an empty dict"
     import types
     result = testutil.call(cherrypy.root.welcome)
     assert type(result) == types.DictType
开发者ID:ccnmtl,项目名称:maap,代码行数:5,代码来源:test_controllers.py

示例8: test_yyy

    def test_yyy(self):
        '''Running the whole application. The output can be found in devdata.sqlite for 
        further use'''

        #create Location
        result = self.calldefault('london','create_location',name='dublin')
        assert 'dublin' in testutil.call(cherrypy.root.listlocations)
        
        dublin = Location.byName('dublin')

        #create Groups
        for g in ['member','host','director']:
            result = self.calldefault('dublin',
                                      'create_group',
                                      group_name='dublin_' + g,
                                      display_name='Dublin ' +g,
                                      place=dublin.id,
                                      level = g)

        assert 'dublin_host' in  [l.group_name for l in Group.select()]
        
        #create Users
        users = ['host1','host2','member1','member2','director1','director2']
        for name in users:
            level = name[:-1]
            result = self.calldefault('dublin',
                                      'create_user',
                                      user_name=name,
                                      email_address='%[email protected]' % name,
                                      display_name=name,
                                      password = 'test',
                                      #groups = [Group.by_group_name('dublin_' + level).id],
                                      homeplace=dublin.id,
                                      billto=None)
            user = User.by_user_name(name)
            user.addGroup(Group.by_group_name('dublin_'+level))
        print 'Groups: ',user.groups
        assert 'member1' in [r.user_name for r in User.select()]

        

        #create Tariffs

        tariffs = ['tariff1000','tariff2000','tariff3000']
        for tariff in tariffs:
            result = self.calldefault('dublin',
                                      'create_resource',
                                      place = dublin.id,
                                      name=tariff,
                                      description='Tariff %s in dublin' % tariff,
                                      type='tariff')
         
        assert 'tariff2000' in [r.name for r in Resource.select()]


        #create Resources

        resources = ['printer1','printer2','hotdesk1','hotdesk2','room1','room2']
        for resource in resources:
            result = self.calldefault('dublin',
                                      'create_resource',
                                      place = dublin.id,
                                      name=resource,
                                      description='Resource %s in dublin' % resource,
                                      type=resource[:-1])
        assert 'printer2' in [r.name for r in Resource.select()]

        #create Prices
        
        pricestructure = [[3,2,1],[4,3,2],[5,4,3],[5,4,3],[10,9,8],[13,12,11]]
        
        for i in range(0,6):
            resourcename = resources[i]
            resource=Resource.selectBy(name=resourcename)[0]
            for j in range(0,3):
                self.calldefault('dublin',
                                 'create_pricing',
                                 tariff=Resource.selectBy(name=tariffs[j])[0].id,
                                 cost = pricestructure[i][j],
                                 resources=resource.id,
                                 time_based=resourcename.startswith('room'))


        #create Prices for tariffs

        for tariffname in tariffs:
            tariff = Resource.selectBy(name=tariffname)[0]
            self.calldefault('dublin',
                             'create_pricing',
                             tariff=tariff.id,
                             cost = int(tariffname[-4:-1])/3,
                             resources=tariff.id)

        #We are working with this user only at this time
        user = User.selectBy(user_name='member1')[0]


        from datetime import datetime
        now = datetime.now()
        #Book a tariff
#.........这里部分代码省略.........
开发者ID:mightymau,项目名称:hubspace,代码行数:101,代码来源:test_model.py

示例9: xtest_00010_setup_location

 def xtest_00010_setup_location(self):
     'Set up location Dublin'
     result = self.calldefault('london','create_location',name='dublin',currency='EUR')
     assert 'dublin' in testutil.call(cherrypy.root.listlocations)
开发者ID:mightymau,项目名称:hubspace,代码行数:4,代码来源:test_model.py

示例10: test_vienna3

 def test_vienna3(self):
     'Test within test'
     self.test_vienna2()
     locations = testutil.call(cherrypy.root.listlocations)
     print locations
     assert 1
开发者ID:mightymau,项目名称:hubspace,代码行数:6,代码来源:test_model.py

示例11: test_vienna2

 def test_vienna2(self):
     "Create vienna2"
     result = self.calldefault('london','create_location',name='vienna2')
     locations = testutil.call(cherrypy.root.listlocations)
     assert 'vienna2' in locations
开发者ID:mightymau,项目名称:hubspace,代码行数:5,代码来源:test_model.py

示例12: test_retrieveDictDirectly

 def test_retrieveDictDirectly(self):
     d = testutil.call(cherrypy.root.returnjson)
     assert d["title"] == "Foobar"
开发者ID:thraxil,项目名称:gtreed,代码行数:3,代码来源:test_controllers.py

示例13: test_add_old

def test_add_old():
    "testing to make sure an add via the 0.91 protocol completes"
    UUID = "sheep!"
    OS = "Wintendo"
    platform = "Super Mario"
    bogomips = 2
    systemMemory = 640
    systemSwap = 640
    CPUVendor = "Death"
    CPUModel = "F00F"
    numCPUs = 0
    CPUSpeed = 0
    language = "Newspeak"
    defaultRunlevel = 6
    vendor = "eMachines"
    system = "reboot O'Matic"
    lsbRelease = "OOXML"
    formfactor = "Sparta!"
    kernelVersion = "NT"
    selinux_enabled = False
    selinux_policy = "Security?"
    smoltProtocol = ".91"
    
    token_result = testutil.call(root.token, uuid = UUID)
    assert token_result["prefered_protocol"] == ".91"
    token =  token_result['token']
    
    add_result = testutil.call(root.add, uuid = UUID, OS = OS, \
                               platform = platform, \
                               bogomips = bogomips, \
                               systemMemory = systemMemory, \
                               systemSwap = systemSwap, \
                               CPUVendor = CPUVendor, \
                               CPUModel = CPUModel, \
                               numCPUs = numCPUs, \
                               CPUSpeed = CPUSpeed, \
                               language = language, \
                               defaultRunlevel = defaultRunlevel, \
                               vendor = vendor, \
                               system = system, \
                               token = token, \
                               lsbRelease = lsbRelease, \
                               formfactor = formfactor, \
                               kernelVersion = kernelVersion, \
                               selinux_enabled = selinux_enabled, \
                               selinux_policy = selinux_policy, \
                               smoltProtocol = smoltProtocol)
    
    test_host = Query(Host).selectone_by(uuid=UUID)
    assert test_host.uuid == UUID
    assert test_host.os == OS
    assert test_host.platform == platform
    assert test_host.cpu_model == CPUModel
    assert test_host.num_cpus == numCPUs
    assert test_host.cpu_speed == CPUSpeed
    assert test_host.language == language
    assert test_host.default_runlevel == defaultRunlevel
    assert test_host.vendor == vendor
    assert test_host.system == system
    assert test_host.formfactor == formfactor
    assert test_host.kernel_version == kernelVersion
    assert test_host.selinux_enabled == selinux_enabled
    assert test_host.selinux_policy == selinux_policy
    
    vendor_id = 42
    device_id = 42
    subsys_vendor_id = 43
    subsys_device_id = 44
    bus = "the short one"
    driver = "santaclause"
    cls = "HEGEMONIC"
    description = '"It\'s hot enough to boil a monkey\'s bum!", the Prime Minister said, and her majesty smiled to herself'
    #She's a good sheila, and not at all stuckup
    device = "%s|%s|%s|%s|%s|%s|%s|%s" % (vendor_id,
                                          device_id,
                                          subsys_vendor_id,
                                          subsys_device_id,
                                          bus,
                                          driver,
                                          cls,
                                          description)
    device = "%s\n%s" % (device, device)
    addDevice_result = testutil.call(root.addDevices, uuid=UUID, Devices=device)
    
    test_device = Query(ComputerLogicalDevice).selectone_by(description=description)
    
    assert test_device.description == description
    assert test_device.vendor_id == vendor_id
    assert test_device.device_id == device_id
    assert test_device.subsys_vendor_id == subsys_vendor_id
    assert test_device.subsys_device_id == subsys_device_id
    assert test_device.bus == bus
    assert test_device.driver == driver
    assert test_device.hardware_class.cls == cls
    
    test_host_link = Query(HostLink).select_by(device_id=test_device.id)[0]
    
    assert test_host_link.device_id == test_device.id
    assert test_host_link.host_link_id == test_host.id
    
#.........这里部分代码省略.........
开发者ID:MythTV,项目名称:smolt,代码行数:101,代码来源:test_controllers.py

示例14: test_add_new

def test_add_new():
    """Testing to make sure an add with the new protocol works"""
    smoltProtocol = "0.97"
    UUID = "sheep!"
    OS = "Wintendo"
    platform = "Super Mario"
    bogomips = 2
    systemMemory = 640
    systemSwap = 640
    CPUVendor = "Death"
    CPUModel = "F00F"
    numCPUs = 0
    CPUSpeed = 0
    language = "Newspeak"
    defaultRunlevel = 6
    vendor = "eMachines"
    system = "reboot O'Matic"
    lsbRelease = "OOXML"
    formfactor = "skinny"
    kernelVersion = "NT"
    selinux_enabled = False
    selinux_policy = "Security?"
    vendor_id = 42
    device_id = 42
    subsys_vendor_id = 43
    subsys_device_id = 44
    bus = "the short one"
    driver = "santaclause"
    cls = "HEGEMONIC"
    description = '"It\'s hot enough to boil a monkey\'s bum!", the Prime Minister said, and her majesty smiled to herself'
    #She's a good sheila, and not at all stuckup
    
    host = {'uuid' :            "sheep!",
            'os' :              "Wintendo",
            'default_runlevel': 6,
            'language' :        "Newspeak",
            'platform' :        "Super Mario",
            'bogomips' :        2,
            'cpu_vendor' :      "Death",
            'cpu_model' :       "F00F",
            'num_cpus':         0,
            'cpu_speed' :       0,
            'system_memory' :   640,
            'system_swap' :     640,
            'vendor' :          "eMachines",
            'system' :          "reboot O'Matic",
            'kernel_version' :  "NT",
            'formfactor' :      "skinny",
            'selinux_enabled':  False,
            'selinux_policy':  "Security?"}
    device = [{"vendor_id": 42,
               "device_id": 42,
               "subsys_vendor_id": 43,
               "subsys_device_id": 44,
               "bus": "the short one",
               "driver": "santaclause",
               "type": "HEGEMONIC",
               "description": '"It\'s hot enough to boil a monkey\'s bum!", the Prime Minister said, and her majesty smiled to herself'}]
    #She's a good sheila, and not at all stuckup
    host["devices"] = device
    host['smolt_protocol'] = smoltProtocol
    host_json = simplejson.dumps(host)
    

    
    token_result = testutil.call(root.token_json, uuid = UUID)
    assert token_result["prefered_protocol"] == "0.97"
    token =  token_result['token']
    
    add_result = testutil.call(root.add_json, uuid=host['uuid'],
                               smolt_protocol=smoltProtocol,
                               token=token, host=host_json)
    
    test_host = Query(Host).selectone_by(uuid=UUID)
    assert test_host.uuid == UUID
    assert test_host.os == OS
    assert test_host.platform == platform
    assert test_host.cpu_model == CPUModel
    assert test_host.num_cpus == numCPUs
    assert test_host.cpu_speed == CPUSpeed
    assert test_host.language == language
    assert test_host.default_runlevel == defaultRunlevel
    assert test_host.vendor == vendor
    assert test_host.system == system
    assert test_host.formfactor == formfactor
    assert test_host.kernel_version == kernelVersion
    assert test_host.selinux_enabled == selinux_enabled
    assert test_host.selinux_policy == selinux_policy
    
    test_device = Query(ComputerLogicalDevice).selectone_by(description=description)
    
    assert test_device.description == description
    assert test_device.vendor_id == vendor_id
    assert test_device.device_id == device_id
    assert test_device.subsys_vendor_id == subsys_vendor_id
    assert test_device.subsys_device_id == subsys_device_id
    assert test_device.bus == bus
    assert test_device.driver == driver
    assert test_device.hardware_class.cls == cls
    
#.........这里部分代码省略.........
开发者ID:MythTV,项目名称:smolt,代码行数:101,代码来源:test_controllers.py

示例15: test_method

def test_method():
    "the index method should return a string called now"
    import types
    result = testutil.call(cherrypy.root.index)
    assert type(result["now"]) == types.StringType
开发者ID:BackupTheBerlios,项目名称:mesa-svn,代码行数:5,代码来源:test_controllers.py


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