當前位置: 首頁>>代碼示例>>Python>>正文


Python KolabWAPTestHelpers.startKolabServer方法代碼示例

本文整理匯總了Python中helperKolabWAP.KolabWAPTestHelpers.startKolabServer方法的典型用法代碼示例。如果您正苦於以下問題:Python KolabWAPTestHelpers.startKolabServer方法的具體用法?Python KolabWAPTestHelpers.startKolabServer怎麽用?Python KolabWAPTestHelpers.startKolabServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在helperKolabWAP.KolabWAPTestHelpers的用法示例。


在下文中一共展示了KolabWAPTestHelpers.startKolabServer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: KolabAutoCreateFolders

# 需要導入模塊: from helperKolabWAP import KolabWAPTestHelpers [as 別名]
# 或者: from helperKolabWAP.KolabWAPTestHelpers import startKolabServer [as 別名]
class KolabAutoCreateFolders(unittest.TestCase):

    def setUp(self):
        self.kolabWAPhelper = KolabWAPTestHelpers()
        self.driver = self.kolabWAPhelper.init_driver()

    def helper_modify_autocreate_folders(self):
        # read kolab.conf
        fo = open("/etc/kolab/kolab.conf", "r+")
        content = fo.read()
        fo.close()
        
        newContactsFolderName = "Contacts" + datetime.datetime.now().strftime("%H%M%S")

        # find [kolab], find line starting with 'Contacts, replace with 'Contacts125559': {
        pos = content.index("[kolab]")
        pos = content.index("'Contacts", pos)
        posAfter = content.index(": {", pos)
        
        content = content[:pos] + "'" + newContactsFolderName + "'" + content[posAfter:]
        
        # write kolab.conf
        fo = open("/etc/kolab/kolab.conf", "wb")
        fo.write(content)
        fo.close()

        # restart kolabd to pickup the changed kolab.conf file
        self.kolabWAPhelper.startKolabServer("restart")
        
        self.kolabWAPhelper.log("kolab.conf has been changed, autocreate_folders now contains " + newContactsFolderName)
        
        return newContactsFolderName

    def test_modified_foldername(self):

        kolabWAPhelper = self.kolabWAPhelper
        kolabWAPhelper.log ("Running test: test_modified_foldername")
        
        # login
        kolabWAPhelper.login_kolab_wap("/kolab-webadmin", "cn=Directory Manager", "test")

        #modify the default folders in /etc/kolab/kolab.conf
        newContactsFolderName = self.helper_modify_autocreate_folders()

        username, emailLogin, password = kolabWAPhelper.create_user()

        kolabWAPhelper.logout_kolab_wap()

        # check if mailbox has been created, with the modified folder name
        out = ""
        starttime=datetime.datetime.now()
        while newContactsFolderName not in out and (datetime.datetime.now()-starttime).seconds < 60:
           kolabWAPhelper.wait_loading(1)
           p = subprocess.Popen("kolab list-mailboxes | grep " + username, shell=True, stdout=subprocess.PIPE)
           out, err = p.communicate()
        if newContactsFolderName not in out:
           self.assertTrue(False, "kolab lm cannot find mailbox with folder " + newContactsFolderName + " for new user " + username)

    def test_modified_foldername_in_new_domain(self):

        kolabWAPhelper = self.kolabWAPhelper
        kolabWAPhelper.log ("Running test: test_modified_foldername_in_new_domain")
        
        # login
        kolabWAPhelper.login_kolab_wap("/kolab-webadmin", "cn=Directory Manager", "test")

        domainname = kolabWAPhelper.create_domain()

        #modify the default folders in /etc/kolab/kolab.conf
        newContactsFolderName = self.helper_modify_autocreate_folders()

        username, emailLogin, password = kolabWAPhelper.create_user()

        kolabWAPhelper.logout_kolab_wap()

        # check if mailbox has been created, with the modified folder name
        out = ""
        starttime=datetime.datetime.now()
        while newContactsFolderName not in out and (datetime.datetime.now()-starttime).seconds < 60:
           kolabWAPhelper.wait_loading(1)
           p = subprocess.Popen("kolab list-mailboxes | grep " + username, shell=True, stdout=subprocess.PIPE)
           out, err = p.communicate()
        if newContactsFolderName not in out:
            self.assertTrue(False, "kolab lm cannot find mailbox with folder " + newContactsFolderName + " for new user " + username)

    def tearDown(self):
        
        # write current page for debugging purposes
        self.kolabWAPhelper.log_current_page()
        
        self.driver.quit()
開發者ID:Celera,項目名稱:KolabScripts,代碼行數:93,代碼來源:testAutoCreateFolders.py


注:本文中的helperKolabWAP.KolabWAPTestHelpers.startKolabServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。