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


Python session.refresh函数代码示例

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


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

示例1: test_group_modify_add_member

    def test_group_modify_add_member(self):
        with session.begin():
            user = data_setup.create_user()


        out = run_client(['bkr', 'group-modify',
                          '--add-member', user.user_name,
                          self.group.group_name],
                         config = self.client_config)

        with session.begin():
            session.refresh(self.group)
            group = Group.by_name(self.group.group_name)
            self.assert_(user.user_name in
                         [u.user_name for u in group.users])


        self.check_notification(user, group, action='Added')

        try:
            out = run_client(['bkr', 'group-modify',
                              '--add-member', 'idontexist',
                              self.group.group_name],
                             config = self.client_config)
            self.fail('Must fail or die')
        except ClientError, e:
            self.assert_('User does not exist' in
                         e.stderr_output, e.stderr_output)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:28,代码来源:test_group_modify.py

示例2: test_system

    def test_system(self):
        login(self.browser)
        orig_date_modified = self.system.date_modified
        self.import_csv((u'csv_type,fqdn,location,arch\n'
                u'system,%s,Under my desk,ia64' % self.system.fqdn)
                .encode('utf8'))
        self.failUnless(is_text_present(self.browser, "No Errors"))
        with session.begin():
            session.refresh(self.system)
            self.assertEquals(self.system.location, u'Under my desk')
            self.assert_(Arch.by_name(u'ia64') in self.system.arch)
            self.assert_(self.system.date_modified > orig_date_modified)

        # attempting to import a system with no FQDN should fail
        self.import_csv((u'csv_type,fqdn,location,arch\n'
                         u'system,'',Under my desk,ia64').encode('utf8'))
        self.assertEquals(self.browser.find_element_by_xpath(
            '//table[@id="csv-import-log"]//td').text,
                          "Error importing line 2: "
                          "System must have an associated FQDN")

        # attempting to import a system with an invalid FQDN should fail
        self.import_csv((u'csv_type,fqdn,location,arch\n'
                         u'system,invalid--fqdn,Under my desk,ia64').encode('utf8'))
        self.assertEquals(self.browser.find_element_by_xpath(
            '//table[@id="csv-import-log"]//td').text,
                          "Error importing line 2: "
                          "Invalid FQDN for system: invalid--fqdn")
开发者ID:ShaolongHu,项目名称:beaker,代码行数:28,代码来源:test_csv_import.py

示例3: test_system_export_reimport

 def test_system_export_reimport(self):
     login(self.browser)
     orig_date_modified = self.system.date_modified
     self.import_csv(''.join([row for row in self.get_csv('system')]))
     self.failUnless(is_text_present(self.browser, "No Errors"))
     session.refresh(self.system)
     self.assert_(orig_date_modified != self.system.date_modified)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:7,代码来源:test_csv_roundtrip.py

示例4: test_group_modify_group_name

    def test_group_modify_group_name(self):
        group_name = 'mynewgroup'
        out = run_client(['bkr', 'group-modify',
                          '--group-name', group_name,
                          self.group.group_name],
                         config = self.client_config)

        with session.begin():
            session.refresh(self.group)
            group = Group.by_name(group_name)
            self.assertEquals(group.group_name, group_name)
            self.assertEquals(group.activity[-1].action, u'Changed')
            self.assertEquals(group.activity[-1].field_name, u'Name')
            self.assertEquals(group.activity[-1].user.user_id,
                              self.user.user_id)
            self.assertEquals(group.activity[-1].new_value, group_name)
            self.assertEquals(group.activity[-1].service, u'XMLRPC')

        try:
            out = run_client(['bkr', 'group-modify',
                              '--group-name', 'areallylonggroupname'*20,
                              self.group.group_name],
                             config = self.client_config)
            self.fail('Must fail or die')
        except ClientError,e:
            max_length = Group.group_name.property.columns[0].type.length
            self.assertRegexpMatches(e.stderr_output,
                                     'Enter a value (less|not more) than %r characters long' % max_length)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:28,代码来源:test_group_modify.py

示例5: test_untag_distro

 def test_untag_distro(self):
     with session.begin():
         self.distro = data_setup.create_distro(tags=[u'RELEASED', u'STABLE'])
     run_client(['bkr', 'distros-untag', '--name', self.distro.name, 'RELEASED'])
     with session.begin():
         session.refresh(self.distro)
         self.assertEquals(self.distro.tags, [u'STABLE'])
开发者ID:ustbgaofan,项目名称:beaker,代码行数:7,代码来源:test_distros_untag.py

示例6: test_tag_distro

 def test_tag_distro(self):
     with session.begin():
         self.distro = data_setup.create_distro()
     run_client(["bkr", "distros-tag", "--name", self.distro.name, "LOL"])
     with session.begin():
         session.refresh(self.distro)
         self.assert_(u"LOL" in self.distro.tags)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:7,代码来源:test_distros_tag.py

示例7: test_remove_and_add

    def test_remove_and_add(self):
        sel = self.selenium

        self.assert_(any(lca.lab_controller == self.lc
                for lca in self.distro_tree.lab_controller_assocs))

        #Remove
        sel.open("labcontrollers/")
        sel.wait_for_page_to_load('30000')
        sel.click("//a[@onclick=\"has_watchdog('%s')\"]" % self.lc.id)
        sel.wait_for_page_to_load("30000")

        self.failUnless(sel.is_text_present("exact:%s removed" % self.lc))
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.lab_controller is None)
            session.refresh(self.distro_tree)
            self.assert_(not any(lca.lab_controller == self.lc
                    for lca in self.distro_tree.lab_controller_assocs))

        #Re add
        sel.open("labcontrollers/")
        sel.wait_for_page_to_load('30000')
        sel.click("//a[@href='unremove?id=%s']" % self.lc.id)
        sel.wait_for_page_to_load('30000')
        self.failUnless(sel.is_text_present("Succesfully re-added %s" % self.lc.fqdn))
开发者ID:sibiaoluo,项目名称:beaker,代码行数:26,代码来源:test_remove_lc.py

示例8: test_can_add_tag_to_distro

 def test_can_add_tag_to_distro(self):
     self.server.auth.login_password(
             data_setup.ADMIN_USER, data_setup.ADMIN_PASSWORD)
     self.server.distros.tag(self.distro.name, 'HAPPY')
     with session.begin():
         session.refresh(self.distro)
         self.assert_(u'HAPPY' in self.distro.tags)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:7,代码来源:test_distros.py

示例9: test_can_remove_tag_from_distro

 def test_can_remove_tag_from_distro(self):
     self.server.auth.login_password(
             data_setup.ADMIN_USER, data_setup.ADMIN_PASSWORD)
     self.server.distros.untag(self.distro.name, 'SAD')
     with session.begin():
         session.refresh(self.distro)
         self.assert_(u'SAD' not in self.distro.tags)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:7,代码来源:test_distros.py

示例10: review

    def review(self, recipeset, response='Nak', comment='fnord'):
        b = self.browser
        rs = b.find_element_by_xpath('//*[@id="RS_%s"]' % recipeset.id)
        # click response radio button
        rs.find_element_by_xpath('.//label[normalize-space(string(.))="%s"]/input'
                % response).click()
        rs.find_element_by_xpath('.//span[text()="Success"]')
        # click comment link
        rs.find_element_by_link_text('comment').click()
        # click edit button in modal
        b.find_element_by_xpath('//*[contains(@class, "ui-dialog")]'
                '//button[text()="Edit"]').click()
        # type comment
        textarea = b.find_element_by_xpath('//*[contains(@class, "ui-dialog")]//textarea')
        textarea.clear()
        textarea.send_keys(comment)
        # click save button in modal
        b.find_element_by_xpath('//*[contains(@class, "ui-dialog")]'
                '//button[text()="Save"]').click()
        rs.find_element_by_xpath('.//span[text()="Comment saved"]')

        with session.begin():
            session.refresh(recipeset)
            self.assertEquals(unicode(recipeset.nacked.response).lower(),
                    response.lower())
            self.assertEquals(recipeset.nacked.comment, comment)
开发者ID:sujithshankar,项目名称:beaker,代码行数:26,代码来源:test_job_ack.py

示例11: test_group_modify_group_name

    def test_group_modify_group_name(self):
        group_name = u'mynewgroup'
        out = run_client(['bkr', 'group-modify',
                          '--group-name', group_name,
                          self.group.group_name],
                         config = self.client_config)

        with session.begin():
            session.refresh(self.group)
            group = Group.by_name(group_name)
            self.assertEquals(group.group_name, group_name)
            self.assertEquals(group.activity[-1].action, u'Changed')
            self.assertEquals(group.activity[-1].field_name, u'Name')
            self.assertEquals(group.activity[-1].user.user_id,
                              self.user.user_id)
            self.assertEquals(group.activity[-1].new_value, group_name)
            self.assertEquals(group.activity[-1].service, u'HTTP')

        try:
            out = run_client(['bkr', 'group-modify',
                              '--group-name', 'areallylonggroupname'*20,
                              self.group.group_name],
                             config = self.client_config)
            self.fail('Must fail or die')
        except ClientError,e:
            self.assertIn(
                    'Group name must be not more than 255 characters long',
                    e.stderr_output)
开发者ID:beaker-project,项目名称:beaker,代码行数:28,代码来源:test_group_modify.py

示例12: test_add_group

    def test_add_group(self):
        with session.begin():
            group = data_setup.create_group()
            user_password = "password"
            user = data_setup.create_user(password=user_password)
            data_setup.add_user_to_group(user, group)
            orig_date_modified = self.system.date_modified

        # as admin, assign the system to our test group
        self.login()
        sel = self.selenium
        self.go_to_system_view()
        sel.click('//ul[@class="tabbernav"]//a[text()="Groups"]')
        sel.type("groups_group_text", group.group_name)
        sel.click('//form[@name="groups"]//a[text()="Add ( + )"]')
        sel.wait_for_page_to_load("30000")
        self.assertEquals(
            sel.get_xpath_count(
                '//div[normalize-space(@class)="tabbertab"]' '//td[normalize-space(text())="%s"]' % group.group_name
            ),
            1,
        )
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.date_modified > orig_date_modified)

        # as a user in the group, can we see it?
        self.logout()
        self.login(user.user_name, user_password)
        sel.click("link=Available")
        sel.wait_for_page_to_load("30000")
        sel.type("simplesearch", self.system.fqdn)
        sel.submit("systemsearch_simple")
        sel.wait_for_page_to_load("30000")
        self.failUnless(sel.is_text_present(self.system.fqdn))
开发者ID:sibiaoluo,项目名称:beaker,代码行数:35,代码来源:test_system_view.py

示例13: test_system_page

    def test_system_page(self):
        sel = self.selenium
        sel.open('view/%s' % self.system.fqdn)
        sel.wait_for_page_to_load('30000')
        lcs = sel.get_text('//form//table/tbody/tr[10]') #The Lab Controller td
        self.failUnless('%s' % self.lc.fqdn in lcs)
        self.failUnless(self.system.lab_controller is self.lc)

        # Remove it
        sel.open("labcontrollers/")
        sel.wait_for_page_to_load('30000')
        sel.click("//a[@onclick=\"has_watchdog('%s')\"]" % self.lc.id)
        sel.wait_for_page_to_load("30000")

        sel.open('view/%s' % self.system.fqdn)
        sel.wait_for_page_to_load('30000')
        lcs = sel.get_text('//form//table/tbody/tr[10]')
        self.failUnless('%s' % self.lc.fqdn not in lcs)
        with session.begin():
            session.refresh(self.system)
            self.failUnless(not self.system.lab_controller)

        # Re add it
        sel.open("labcontrollers/")
        sel.wait_for_page_to_load('30000')
        sel.click("//a[@href='unremove?id=%s']" % self.lc.id)
        sel.wait_for_page_to_load('30000')
        sel.open('edit/%s' % self.system.fqdn)
        sel.wait_for_page_to_load('30000')
        sel.select("form_lab_controller_id", "label=%s" % self.lc.fqdn)
        sel.click("link=Save Changes")
        sel.wait_for_page_to_load('30000')
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.lab_controller is self.lc)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:35,代码来源:test_remove_lc.py

示例14: test_system_pools_import

    def test_system_pools_import(self):
        with session.begin():
            system = data_setup.create_system()
            pool1 = data_setup.create_system_pool()
            pool2 = data_setup.create_system_pool()

        login(self.browser)
        self.import_csv((u'csv_type,fqdn,pool,deleted\n'
                         u'system_pool,%s,%s,False\n'
                         u'system_pool,%s,%s,False'%(system.fqdn, pool1.name,
                                                     system.fqdn, pool2.name)) \
                        .encode('utf8'))
        self.failUnless(is_text_present(self.browser, 'No Errors'))
        with session.begin():
            session.refresh(system)
            self.assertEquals([pool1.name, pool2.name],
                              [pool.name for pool in system.pools])
        # test deletion
        self.import_csv((u'csv_type,fqdn,pool,deleted\n'
                         u'system_pool,%s,%s,True' % (system.fqdn, pool2.name)) \
                         .encode('utf8'))
        self.failUnless(is_text_present(self.browser, 'No Errors'))
        with session.begin():
            session.refresh(system)
            self.assertNotIn(pool2.name, [pool.name for pool in system.pools])

        # Attempting to add a system to a Non existent pool should throw an error
        self.import_csv((u'csv_type,fqdn,pool,deleted\n'
                         u'system_pool,%s,poolpool,True' % system.fqdn) \
                         .encode('utf8'))
        self.assertTrue(is_text_present(self.browser, 'poolpool: pool does not exist'))
开发者ID:ShaolongHu,项目名称:beaker,代码行数:31,代码来源:test_csv_import.py

示例15: test_remove_and_add

    def test_remove_and_add(self):
        b = self.browser

        self.assert_(any(lca.lab_controller == self.lc
                for lca in self.distro_tree.lab_controller_assocs))

        #Remove
        b.get(get_server_base() + 'labcontrollers/')
        b.find_element_by_xpath('//tr[normalize-space(string(td[1]))="%s"]'
                '//a[contains(text(), "Remove")]' % self.lc.fqdn).click()
        self.assertEquals(b.find_element_by_class_name('flash').text,
                '%s removed' % self.lc)
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.lab_controller is None)
            session.refresh(self.distro_tree)
            self.assert_(not any(lca.lab_controller == self.lc
                    for lca in self.distro_tree.lab_controller_assocs))

        #Re add
        b.get(get_server_base() + 'labcontrollers/')
        b.find_element_by_xpath('//tr[normalize-space(string(td[1]))="%s"]'
                '//a[contains(text(), "Re-Add")]' % self.lc.fqdn).click()
        self.assertEquals(b.find_element_by_class_name('flash').text,
                'Successfully re-added %s' % self.lc)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:25,代码来源:test_remove_lc.py


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