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


Python Test.validators方法代码示例

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


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

示例1: test_get_validators

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
    def test_get_validators(self):
        """ Test that validators work correctly """
        test = Test()
        test.url = self.prefix + "/api/person/"

        # Validators need library calls to configure them
        test.validators = list()
        cfg_exists = {"jsonpath_mini": "objects.0", "test": "exists"}
        test.validators.append(validators.parse_validator("extract_test", cfg_exists))
        cfg_exists_0 = {"jsonpath_mini": "meta.offset", "test": "exists"}
        test.validators.append(validators.parse_validator("extract_test", cfg_exists_0))
        cfg_not_exists = {"jsonpath_mini": "objects.100", "test": "not_exists"}
        test.validators.append(validators.parse_validator("extract_test", cfg_not_exists))
        cfg_compare_login = {"jsonpath_mini": "objects.0.login", "expected": "gbaltar"}
        test.validators.append(validators.parse_validator("compare", cfg_compare_login))
        cfg_compare_id = {"jsonpath_mini": "objects.1.id", "comparator": "gt", "expected": -1}
        test.validators.append(validators.parse_validator("compare", cfg_compare_id))

        test_response = resttest.run_test(test)
        for failure in test_response.failures:
            print("REAL FAILURE")
            print("Test Failure, failure type: {0}, Reason: {1}".format(failure.failure_type, failure.message))
            if failure.details:
                print("Validator/Error details: " + str(failure.details))
        self.assertFalse(test_response.failures)
        self.assertTrue(test_response.passed)
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:28,代码来源:functionaltest.py

示例2: test_get_validators

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
    def test_get_validators(self):
        """ Test that validators work correctly """
        test = Test()
        test.url = self.prefix + '/api/person/'
        
        # Validators need library calls to configure them
        test.validators = list()
        cfg_exists = {'jsonpath_mini': "objects.0", 'test':'exists'}
        test.validators.append(validators.parse_validator('extract_test', cfg_exists))
        cfg_exists_0 = {'jsonpath_mini': "meta.offset", 'test':'exists'}
        test.validators.append(validators.parse_validator('extract_test', cfg_exists_0))
        cfg_not_exists = {'jsonpath_mini': "objects.100", 'test':'not_exists'}
        test.validators.append(validators.parse_validator('extract_test', cfg_not_exists))
        cfg_compare_login = {'jsonpath_mini': 'objects.0.login', 'expected': 'gbaltar'}
        test.validators.append(validators.parse_validator('compare', cfg_compare_login))
        cfg_compare_id = {'jsonpath_mini': 'objects.1.id', 'comparator':'gt', 'expected': -1}
        test.validators.append(validators.parse_validator('compare', cfg_compare_id))

        test_response = resttest.run_test(test)
        for failure in test_response.failures:
            print "REAL FAILURE"
            print "Test Failure, failure type: {0}, Reason: {1}".format(failure.failure_type, failure.message)
            if failure.details:
                print "Validator/Error details: "+str(failure.details)
        self.assertFalse(test_response.failures)
        self.assertTrue(test_response.passed)
开发者ID:LGordon2,项目名称:pyresttest,代码行数:28,代码来源:functionaltest.py

示例3: test_header_validators

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
    def test_header_validators(self):
        test = Test()
        test.url = self.prefix + "/api/person/1/"
        config = {"header": "server", "comparator": "contains", "expected": "WSGI"}
        test.validators = list()
        test.validators.append(validators.parse_validator("comparator", config))
        result = resttest.run_test(test)

        if result.failures:
            for fail in result.failures:
                print(fail)
        self.assertTrue(result.passed)
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:14,代码来源:functionaltest.py

示例4: test_get_validators_fail

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
 def test_get_validators_fail(self):
     """ Test validators that should fail """
     test = Test()
     test.url = self.prefix + "/api/person/"
     test.validators = list()
     cfg_exists = {"jsonpath_mini": "objects.500", "test": "exists"}
     test.validators.append(validators.parse_validator("extract_test", cfg_exists))
     cfg_not_exists = {"jsonpath_mini": "objects.1", "test": "not_exists"}
     test.validators.append(validators.parse_validator("extract_test", cfg_not_exists))
     cfg_compare = {"jsonpath_mini": "objects.1.last_name", "expected": "NotJenkins"}
     test.validators.append(validators.parse_validator("compare", cfg_compare))
     test_response = resttest.run_test(test)
     self.assertFalse(test_response.passed)
     self.assertTrue(test_response.failures)
     self.assertEqual(3, len(test_response.failures))
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:17,代码来源:functionaltest.py

示例5: test_get_validators_fail

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
 def test_get_validators_fail(self):
     """ Test validators that should fail """
     test = Test()
     test.url = self.prefix + '/api/person/'
     test.validators = list()
     cfg_exists = {'jsonpath_mini': "objects.500", 'test':'exists'}
     test.validators.append(validators.parse_validator('extract_test', cfg_exists))
     cfg_not_exists = {'jsonpath_mini': "objects.1", 'test':'not_exists'}
     test.validators.append(validators.parse_validator('extract_test', cfg_not_exists))
     cfg_compare = {'jsonpath_mini': "objects.1.last_name", 'expected':'NotJenkins'}
     test.validators.append(validators.parse_validator('compare', cfg_compare))
     test_response = resttest.run_test(test)
     self.assertFalse(test_response.passed)
     self.assertTrue(test_response.failures)
     self.assertEqual(3, len(test_response.failures))
开发者ID:LGordon2,项目名称:pyresttest,代码行数:17,代码来源:functionaltest.py

示例6: test_header_validators

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import validators [as 别名]
    def test_header_validators(self):
        test = Test()
        test.url = self.prefix + '/api/person/1/'
        config = {
            'header': 'server',
            'comparator': 'contains',
            'expected': 'WSGI'
        }
        test.validators = list()
        test.validators.append(
            validators.parse_validator('comparator', config))
        result = resttest.run_test(test)

        if result.failures:
            for fail in result.failures:
                print(fail)
        self.assertTrue(result.passed)
开发者ID:marklz,项目名称:pyresttest,代码行数:19,代码来源:functionaltest.py


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