def test_merge_validator(self):
        api_validators = [{
            'eq': ['v1', 200]
        }, {
            "check": "s2",
            "expect": 16,
            "comparator": "len_eq"
        }]
        test_validators = [{
            "check": "v1",
            "expect": 201
        }, {
            'len_eq': ['s3', 12]
        }]

        merged_validators = testcase.merge_validator(api_validators,
                                                     test_validators)
        self.assertIn({
            "check": "v1",
            "expect": 201,
            "comparator": "eq"
        }, merged_validators)
        self.assertIn({
            "check": "s2",
            "expect": 16,
            "comparator": "len_eq"
        }, merged_validators)
        self.assertIn({
            "check": "s3",
            "expect": 12,
            "comparator": "len_eq"
        }, merged_validators)
Exemplo n.º 2
0
    def test_merge_validator_with_dict(self):
        api_validators = [
            {'eq': ["a", {"v": 1}]},
            {'eq': [{"b": 1}, 200]}
        ]
        test_validators = [
            {'len_eq': ['s3', 12]},
            {'eq': [{"b": 1}, 201]}
        ]

        merged_validators = testcase.merge_validator(api_validators, test_validators)
        self.assertEqual(len(merged_validators), 3)
        self.assertEqual(merged_validators[1], {'check': {'b': 1}, 'expect': 201, 'comparator': 'eq'})