Пример #1
0
    def test_mass_inference(self):
        """generate many more paths and infer them right away"""
        stree = StringFormatNodeTree.new('root', self.path_rule_data)
        itree = InferenceStringFormatNodeTree.new('root', self.path_rule_data)

        # the delegate only has information about the root path and the project name,
        # everything else will be inferred
        delegate = InferenceStringFormatNodeTreeDelegate([self.base_data().clone()])

        # MASS TEST
        ###########
        # In this test we only have two substitutions, the projects root and the code. All other formats
        # are just names, which should be resolved as well.
        # Make sure we can substitute as many paths as possible, thus we add some more information
        count = 0
        data = self.complete_data()

        assert 'asset' not in delegate.parsed_data(), "precondition failed"
        # we need this predicate, as we may have ambiguity in the tree (at least with our limited dataset)
        predicate = InferenceStringFormatNodeTree.leaf_nodes_only
        for nlist in stree.iterate_formatted_nodes(data):
            count += 1
            matches = list(itree.iterate_matches(nlist.to_string(), delegate=delegate, predicate=predicate))
            assert len(matches) == 1, "should have exactly one full match from a previously generated path"
        # end for each nodelist
        assert count, "should have processed quite some paths"

        # quick diff - there should be no differences (which are not overcome by converting from one type to another)
        validator = KeyValueStoreSchemaValidator()
        for key, value in data.items():
            ValidatedKeyValueStoreSchema(key, value, validator=validator)
        # end for each key, value
        assert type(delegate.parsed_data()['resource']['version']) is int
        assert len(validator) and len(validator.validate_provider(KeyValueStoreProvider(delegate.parsed_data()))) == 0