Пример #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
Пример #2
0
#-*-coding:utf-8-*-
"""
@package bshotgun.schema
@brief defines schemas we use when querying configuration

@author Sebastian Thiel
@copyright [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl.html)
"""
__all__ = ['sql_shotgun_schema', 'shotgun_schema', 'type_factory_schema', 'combined_shotgun_schema']

from butility import Path
from bkvstore import (KeyValueStoreSchema,
                      KeyValueStoreSchemaValidator)


shotgun_schema = KeyValueStoreSchema('shotgun', {'host' : str,
                                                 'api_script' : str,
                                                 'api_token' : str,
                                                 'http_proxy' : str})

type_factory_schema = KeyValueStoreSchema(shotgun_schema.key(), {'schema_cache_tree' : Path})

sql_shotgun_schema = KeyValueStoreSchemaValidator.merge_schemas(
                        (shotgun_schema,
                            KeyValueStoreSchema(shotgun_schema.key(), {'sql_cache_url' : str })))


# this one should contain all the keys
combined_shotgun_schema = KeyValueStoreSchemaValidator.merge_schemas((sql_shotgun_schema, type_factory_schema))