• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.get_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_auth_failure_xml

    def test_auth_failure_xml(self):

        """ Send a configured auth request with a wrong password in XML format
        and check the result
        """

        config = get_config()

        if config.getboolean("auth_test", "enabled"):

            # Run only if enabled

            try:

                timestamp = config.getint("auth_test", "timestamp")

            except ValueError:

                # If timestamp is set to a none-integer, we'll just assume
                # that it's unset

                timestamp = None

            response = authenticate(
                config.get("auth_test", "url"),
                config.get("auth_test", "account"),
                config.get("auth_test", "preauthkey") + "1234",
                config.get("auth_test", "account_by"),
                config.getint("auth_test", "expires"),
                timestamp,
            )

            self.assertEqual(response, None, "Authentication did not return 'None', but %s instead." % (response))
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:33,代码来源:test_auth.py


示例2: test_fault_non_existing_folder_genrequest_invalidurl

    def test_fault_non_existing_folder_genrequest_invalidurl(self):
        """ Request a non existing folder, so we get a fitting fault
        """

        config = get_config()

        if config.getboolean('fault_test', 'enabled'):

            comm = Communication(config.get('fault_test', 'url') + "1234")

            token = auth.authenticate(config.get('fault_test', 'url'),
                                      config.get('fault_test', 'account'),
                                      config.get('fault_test', 'preauthkey'),
                                      config.get('fault_test', 'account_by'))

            request = comm.gen_request(token=token)

            request.add_request(
                "GetFolderRequest",
                {
                    "folder": {
                        "path": config.get('fault_test', 'folder')
                    }
                },
                "urn:zimbraMail"
            )

            # A 404 error should by raised as an exception.

            self.assertRaises(
                Exception,
                comm.send_request,
                request
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:34,代码来源:test_fault.py


示例3: test_fault_non_existing_folder_genrequest_xml

    def test_fault_non_existing_folder_genrequest_xml(self):
        """ Request a non existing folder, so we get a fitting fault
        """

        config = get_config()

        if config.getboolean('fault_test', 'enabled'):

            comm = Communication(config.get('fault_test', 'url'))

            token = auth.authenticate(config.get('fault_test', 'url'),
                                      config.get('fault_test', 'account'),
                                      config.get('fault_test', 'preauthkey'),
                                      config.get('fault_test', 'account_by'))

            request = comm.gen_request(request_type="xml", token=token)

            request.add_request(
                "GetFolderRequest",
                {
                    "folder": {
                        "path": config.get('fault_test', 'folder')
                    }
                },
                "urn:zimbraMail"
            )

            response = comm.send_request(request)

            self.check_response(
                response
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:32,代码来源:test_fault.py


示例4: test_auth_failure_raise

    def test_auth_failure_raise(self):

        """ Send a configured auth request with a wrong password in json
        format and let it raise an exception
        """

        config = get_config()

        if config.getboolean("auth_test", "enabled"):

            # Run only if enabled

            try:

                timestamp = config.getint("auth_test", "timestamp")

            except ValueError:

                # If timestamp is set to a none-integer, we'll just assume
                # that it's unset

                timestamp = None

            self.assertRaises(
                AuthenticationFailed,
                authenticate,
                config.get("auth_test", "url"),
                config.get("auth_test", "account"),
                config.get("auth_test", "preauthkey") + "1234",
                config.get("auth_test", "account_by"),
                config.getint("auth_test", "expires"),
                timestamp,
                request_type="json",
                raise_on_error=True,
            )
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:35,代码来源:test_auth.py


示例5: test_password_auth_xml

    def test_password_auth_xml(self):

        """ Send a configured auth request in xml format using password
        based authentication and check a successfully returned token
        """

        config = get_config()

        if config.getboolean("auth_by_password_test", "enabled"):

            # Run only if enabled

            response = authenticate(
                config.get("auth_by_password_test", "url"),
                config.get("auth_by_password_test", "account"),
                config.get("auth_by_password_test", "password"),
                config.get("auth_by_password_test", "account_by"),
                use_password=True,
                request_type="xml"
            )

            if response is None:

                self.fail("Authentication with the configured settings "
                          "was not ssuccessful")
开发者ID:denisvm,项目名称:python-zimbra,代码行数:25,代码来源:test_auth.py


示例6: test_admin_auth_json

    def test_admin_auth_json(self):

        """ Send a configured admin auth request in json format using the
        admin auth-method and check a successfully returned token
        """

        config = get_config()

        if config.getboolean("admin_auth_test", "enabled"):

            # Run only if enabled

            response = authenticate(
                config.get("admin_auth_test", "url"),
                config.get("admin_auth_test", "account"),
                config.get("admin_auth_test", "password"),
                config.get("admin_auth_test", "account_by"),
                admin_auth=True,
                request_type="json"
            )

            if response is None:

                self.fail("Authentication with the configured settings "
                          "was not successful")
开发者ID:denisvm,项目名称:python-zimbra,代码行数:25,代码来源:test_auth.py


示例7: test_auth_xml

    def test_auth_xml(self):

        """ Send a configured auth request in XML format and check a
        successfully returned token
        """

        config = get_config()

        if config.getboolean("auth_test", "enabled"):

            # Run only if enabled

            try:

                timestamp = config.getint("auth_test", "timestamp")

            except ValueError:

                # If timestamp is set to a none-integer, we'll just assume
                # that it's unset

                timestamp = None

            response = authenticate(
                config.get("auth_test", "url"),
                config.get("auth_test", "account"),
                config.get("auth_test", "preauthkey"),
                config.get("auth_test", "account_by"),
                config.getint("auth_test", "expires"),
                timestamp,
            )

            self.assertNotEqual(response, None, "Authentication with the configured settings " "was not successful")
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:33,代码来源:test_auth.py


示例8: generate_test

def generate_test(file):
    """ Generate a given test. """
    import tests
    config = tests.get_config(os.path.dirname(file))
    root, ext = os.path.splitext(file)
    if ext == config.get(get_section(os.path.basename(root), config), 
                         'input_ext'):
        tests.generate(root, config)
    else:
        print test, 'does not have a valid file extension. Check config.'
开发者ID:kgrinberg,项目名称:Python-Markdown,代码行数:10,代码来源:fabfile.py


示例9: test_autoresponse_xml

    def test_autoresponse_xml(self):

        """ Create an XML-request and pass this to send_request expection a
        xml response.
        """

        config = get_config()

        if config.getboolean("autoresponse_test", "enabled"):

            # Run only if enabled

            token = authenticate(
                config.get("autoresponse_test", "url"),
                config.get("autoresponse_test", "account"),
                config.get("autoresponse_test", "preauthkey")
            )

            self.assertNotEqual(
                token,
                None,
                "Cannot authenticate."
            )

            request = RequestXml()
            request.set_auth_token(token)
            request.add_request(
                "NoOpRequest",
                {

                },
                "urn:zimbraMail"
            )

            comm = Communication(config.get("autoresponse_test", "url"))

            response = comm.send_request(request)

            if response.is_fault():

                self.fail(
                    "Reponse failed: (%s) %s" % (
                        response.get_fault_code(),
                        response.get_fault_message()
                    )
                )

            self.assertEqual(
                response.response_type,
                "xml",
                "Invalid response type %s" % response.response_type
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:52,代码来源:test_autoresponse.py


示例10: generate_test

def generate_test(file):
    """ Generate a given test. """
    import sys, os

    sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
    import tests

    config = tests.get_config(os.path.dirname(file))
    root, ext = os.path.splitext(file)
    if ext == config.get(tests.get_section(os.path.basename(root), config), "input_ext"):
        tests.generate(root, config)
    else:
        print file, "does not have a valid file extension. Check config."
开发者ID:netscokhlee,项目名称:Python-Markdown,代码行数:13,代码来源:fabfile.py


示例11: test_genrequest_fail

    def test_genrequest_fail(self):

        """ Create a request only using the Communication-object
        """

        config = get_config()

        if config.getboolean("genrequest_test", "enabled"):

            # Run only if enabled

            comm = Communication(config.get("genrequest_test", "url"))

            token = authenticate(
                config.get("genrequest_test", "url"),
                config.get("genrequest_test", "account"),
                config.get("genrequest_test", "preauthkey")
            )

            self.assertNotEqual(
                token,
                None,
                "Cannot authenticate."
            )

            self.assertRaises(
                UnknownRequestType,
                comm.gen_request,
                request_type="INVALID",
                token=token
            )

            request = comm.gen_request(token=token)

            request.add_request(
                "NoOpRequest",
                {

                },
                "urn:zimbraMail"
            )

            # Deliberately break the request

            request.request_type = "INVALID"

            self.assertRaises(
                UnknownRequestType,
                comm.send_request,
                request
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:51,代码来源:test_genrequest.py


示例12: test_genrequest_check_response_xml

    def test_genrequest_check_response_xml(self):

        """ Create a request only using the Communication-object, send it and
            check the response
        """

        config = get_config()

        if config.getboolean("genrequest_test", "enabled"):

            # Run only if enabled

            comm = Communication(config.get("genrequest_test", "url"))

            token = authenticate(
                config.get("genrequest_test", "url"),
                config.get("genrequest_test", "account"),
                config.get("genrequest_test", "preauthkey")
            )

            self.assertNotEqual(
                token,
                None,
                "Cannot authenticate."
            )

            request = comm.gen_request(request_type="xml", token=token)

            request.add_request(
                "GetInfoRequest",
                {
                },
                "urn:zimbraAccount"
            )

            response = comm.send_request(request)

            if response.is_fault():

                self.fail(
                    "Reponse failed: (%s) %s" % (
                        response.get_fault_code(),
                        response.get_fault_message()
                    )
                )

            self.assertEqual(
                response.get_response()["GetInfoResponse"]["name"],
                config.get("genrequest_test", "account"),
                "Request returned unexpected response"
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:51,代码来源:test_genrequest.py


示例13: test_genrequest_xml

    def test_genrequest_xml(self):

        """ Create a request only using the Communication-object
        """

        config = get_config()

        if config.getboolean("genrequest_test", "enabled"):

            # Run only if enabled

            comm = Communication(config.get("genrequest_test", "url"))

            token = authenticate(
                config.get("genrequest_test", "url"),
                config.get("genrequest_test", "account"),
                config.get("genrequest_test", "preauthkey")
            )

            self.assertNotEqual(
                token,
                None,
                "Cannot authenticate."
            )

            request = comm.gen_request(request_type="xml", token=token)

            request.add_request(
                "NoOpRequest",
                {

                },
                "urn:zimbraMail"
            )

            response = comm.send_request(request)

            if response.is_fault():

                self.fail(
                    "Reponse failed: (%s) %s" % (
                        response.get_fault_code(),
                        response.get_fault_message()
                    )
                )

            self.assertEqual(
                response.response_type,
                "xml",
                "Invalid response type %s" % response.response_type
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:51,代码来源:test_genrequest.py


示例14: check_response

    def check_response(self, response):

        # Should be a fault

        if not response.is_fault():

            self.fail(
                "Response wasn't a fault: %s" % (response.get_response())
            )

        config = get_config()

        message = "no such folder path: %s" % config.get('fault_test', 'folder')

        if response.is_batch():

            # Correct error should've been returned

            for request_id, code in response.get_fault_code().items():

                self.assertEqual(
                    "mail.NO_SUCH_FOLDER",
                    code
                )

            # Correct error message should've been returned

            for request_id, fault_message in \
                    response.get_fault_message().items():

                self.assertEqual(
                    message,
                    fault_message
                )

        else:

            # Correct error should've been returned

            self.assertEqual(
                "mail.NO_SUCH_FOLDER",
                response.get_fault_code()
            )

            # Correct error message should've been returned

            self.assertEqual(
                message,
                response.get_fault_message()
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:50,代码来源:test_fault.py


示例15: test_fault_non_existing_folder_batch_json

    def test_fault_non_existing_folder_batch_json(self):

        """ Request a non existing folder multiple times to get multiple
        faults
        """

        config = get_config()

        if config.getboolean('fault_test', 'enabled'):

            comm = Communication(config.get('fault_test', 'url'))

            token = auth.authenticate(config.get('fault_test', 'url'),
                                      config.get('fault_test', 'account'),
                                      config.get('fault_test', 'preauthkey'),
                                      config.get('fault_test', 'account_by'))

            request = RequestJson()

            request.set_auth_token(token)

            request.enable_batch()

            request.add_request(
                "GetFolderRequest",
                {
                    "folder": {
                        "path": config.get('fault_test', 'folder')
                    }
                },
                "urn:zimbraMail"
            )

            request.add_request(
                "GetFolderRequest",
                {
                    "folder": {
                        "path": config.get('fault_test', 'folder')
                    }
                },
                "urn:zimbraMail"
            )

            response = ResponseJson()

            comm.send_request(request, response)

            self.check_response(
                response
            )
开发者ID:Zimbra-Community,项目名称:python-zimbra,代码行数:50,代码来源:test_fault.py


示例16: test_password_auth_json

    def test_password_auth_json(self):

        """ Send a configured auth request in json format using password
        based authentication and check a successfully returned token
        """

        config = get_config()

        if config.getboolean("auth_by_password_test", "enabled"):

            # Run only if enabled

            response = authenticate(
                config.get("auth_by_password_test", "url"),
                config.get("auth_by_password_test", "account"),
                config.get("auth_by_password_test", "password"),
                config.get("auth_by_password_test", "account_by"),
                use_password=True,
                request_type="json",
            )

            self.assertNotEqual(response, None, "Authentication with the configured settings " "was not successful")
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:22,代码来源:test_auth.py


示例17: test_password_auth_failure_json

    def test_password_auth_failure_json(self):

        """ Send a configured auth request in json format using password based
        authentication and a wrong password and check the error
        """

        config = get_config()

        if config.getboolean("auth_by_password_test", "enabled"):

            # Run only if enabled

            response = authenticate(
                config.get("auth_by_password_test", "url"),
                config.get("auth_by_password_test", "account"),
                config.get("auth_by_password_test", "password") + "1234",
                config.get("auth_by_password_test", "account_by"),
                use_password=True,
                request_type="json",
            )

            self.assertEqual(response, None, "Authentication with a bad password" "was successful")
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:22,代码来源:test_auth.py


示例18: test_admin_auth_xml

    def test_admin_auth_xml(self):

        """ Send a configured admin auth request in xml format using the
        admin auth-method and check a successfully returned token
        """

        config = get_config()

        if config.getboolean("admin_auth_test", "enabled"):

            # Run only if enabled

            response = authenticate(
                config.get("admin_auth_test", "admin_url"),
                config.get("admin_auth_test", "admin_account"),
                config.get("admin_auth_test", "admin_password"),
                config.get("admin_auth_test", "admin_account_by"),
                admin_auth=True,
                request_type="xml",
            )

            self.assertNotEqual(response, None, "Authentication with the configured settings " "was not successful")
开发者ID:fsschmidt,项目名称:python-zimbra,代码行数:22,代码来源:test_auth.py


示例19: test_auth_json

        def test_auth_json(self):

            """ Send a configured auth request in json format and check a
            successfully returned token
            """

            config = get_config()

            if config.getboolean('auth_test', 'enabled'):

                # Run only if enabled

                try:

                    timestamp = config.getint('auth_test', 'timestamp')

                except ValueError:

                    # If timestamp is set to a none-integer, we'll just assume
                    # that it's unset

                    timestamp = None

                response = authenticate(
                    config.get('auth_test', 'url'),
                    config.get('auth_test', 'account'),
                    config.get('auth_test', 'preauthkey'),
                    config.get('auth_test', 'account_by'),
                    config.getint('auth_test', 'expires'),
                    timestamp,
                    request_type='json'
                )

                if response is None:

                    self.fail("Authentication with the configured settings "
                              "was not successful")
开发者ID:JocelynDelalande,项目名称:python-zimbra,代码行数:37,代码来源:test_auth.py


示例20: len

#!/usr/bin/env python

import tests
import os, sys

if len(sys.argv) > 1 and sys.argv[1] == "update":
    if len(sys.argv) > 2:
        config = tests.get_config(os.path.dirname(sys.argv[2]))
        root, ext = os.path.splitext(sys.argv[2])
        if ext == config.get(tests.get_section(os.path.basename(root), config), 'input_ext'):
            tests.generate(root, config)
        else:
            print(sys.argv[2], 'does not have a valid file extension. Check config.')
    else:
        tests.generate_all()
else:
    tests.run()
开发者ID:manikanta-kumar-allakki,项目名称:polls-india,代码行数:17,代码来源:run-tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.get_data_path函数代码示例发布时间:2022-05-27
下一篇:
Python tests.fetch_file函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap