Пример #1
0
def test_inheritance_yaml():
    test_file = os.path.join("tests", "fixtures", "child.yaml")
    data = open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
    eq_(data, {
        "key": "hello world",
        "pass": "******"
    })
Пример #2
0
def handle_moban_file(moban_file, options):
    """
    act upon default moban file
    """
    moban_file_configurations = open_yaml(None, moban_file)
    if moban_file_configurations is None:
        raise exceptions.MobanfileGrammarException(
            constants.ERROR_INVALID_MOBAN_FILE % moban_file
        )
    if (
        constants.LABEL_TARGETS not in moban_file_configurations
        and constants.LABEL_COPY not in moban_file_configurations
    ):
        raise exceptions.MobanfileGrammarException(
            constants.ERROR_NO_TARGETS % moban_file
        )
    version = moban_file_configurations.get(
        constants.MOBAN_VERSION, constants.DEFAULT_MOBAN_VERSION
    )
    if version == constants.DEFAULT_MOBAN_VERSION:
        mobanfile.handle_moban_file_v1(moban_file_configurations, options)
    else:
        raise exceptions.MobanfileGrammarException(
            constants.MESSAGE_FILE_VERSION_NOT_SUPPORTED % version
        )
    HASH_STORE.save_hashes()
Пример #3
0
 def get_data(self, file_name):
     file_extension = os.path.splitext(file_name)[1]
     if file_extension == ".json":
         data = utils.open_json(self.context_dirs, file_name)
     elif file_extension in [".yml", ".yaml"]:
         data = utils.open_yaml(self.context_dirs, file_name)
         utils.merge(data, self.__cached_environ_variables)
     else:
         raise exceptions.IncorrectDataInput
     return data
Пример #4
0
def handle_moban_file(options):
    """
    act upon default moban file
    """
    moban_file_configurations = open_yaml(
        None,
        constants.DEFAULT_MOBAN_FILE)
    if moban_file_configurations is None:
        print(ERROR_INVALID_MOBAN_FILE % constants.DEFAULT_MOBAN_FILE)
        sys.exit(-1)
    if constants.LABEL_TARGETS not in moban_file_configurations:
        print(ERROR_NO_TARGETS % constants.DEFAULT_MOBAN_FILE)
        sys.exit(0)
    version = moban_file_configurations.get(
        constants.MOBAN_VERSION,
        constants.DEFAULT_MOBAN_VERSION
    )
    if version == constants.DEFAULT_MOBAN_VERSION:
        handle_moban_file_v1(moban_file_configurations, options)
    else:
        raise NotImplementedError(
            "moban file version %d is not supported" % version)
Пример #5
0
 def get_data(self, file_name):
     data = utils.open_yaml(self.context_dirs, file_name)
     utils.merge(data, self.__cached_environ_variables)
     return data
Пример #6
0
 def get_data(self, file_name):
     return open_yaml(self.context_dirs, file_name)
Пример #7
0
def test_simple_yaml():
    test_file = os.path.join("tests", "fixtures", "simple.yaml")
    data = open_yaml(os.path.join("tests", "fixtures"), test_file)
    eq_(data, {"simple": "yaml"})
Пример #8
0
def test_exception_3():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(None, test_file)
Пример #9
0
def test_exception_2():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
Пример #10
0
def test_inheritance_yaml():
    test_file = os.path.join("tests", "fixtures", "child.yaml")
    data = open_yaml(os.path.join("tests", "fixtures", "config"), test_file)
    eq_(data, {"key": "hello world", "pass": "******"})
Пример #11
0
def test_simple_yaml():
    test_file = os.path.join("tests", "fixtures", "simple.yaml")
    data = open_yaml(os.path.join("tests", "fixtures"), test_file)
    eq_(data, {
        "simple": "yaml"
    })
Пример #12
0
def test_exception_3():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(None, test_file)
Пример #13
0
def test_exception_2():
    test_file = os.path.join("tests", "fixtures", "dragon.yaml")
    open_yaml(os.path.join("tests", "fixtures", "config"), test_file)