Пример #1
0
def test_basic():
    with tempdir():
        for doc in run_dexy_without_tempdir(BASIC_CONFIG):
            doc.run()
            assert doc.artifacts[-1].source == 'run'

        for doc in run_dexy_without_tempdir(BASIC_CONFIG):
            doc.run()
            assert doc.artifacts[-1].source == 'cache'
Пример #2
0
def test_args_copied():
    config = {
        "." : {
            "*.md|jinja" : { "inputs" : ["*.txt"] },
            "*.txt" : { "meta" : 5 }
        },
    }

    with tempdir():
        for filename in ["abc.txt", "def.txt", "template.md"]:
            with open(filename, "w") as f:
                f.write("hello")

        i = 0
        for doc in run_dexy_without_tempdir(config):
            i += 1
            doc.run()
            if doc.key().endswith(".txt"):
                assert doc.output() == "hello"
                assert doc.last_artifact.args['meta'] == 5
                assert len(doc.inputs) == 0
            elif doc.key().endswith(".md"):
                assert len(doc.inputs) == 2

        assert i == 3
Пример #3
0
def test_inputs():
    with tempdir():
        for doc in run_dexy_without_tempdir(CONFIG_WITH_INPUT_1):
            doc.run()
            assert doc.artifacts[-1].source == 'run'

        for doc in run_dexy_without_tempdir(CONFIG_WITH_INPUT_1):
            doc.run()
            assert doc.artifacts[-1].source == 'cache'

        for doc in run_dexy_without_tempdir(CONFIG_WITH_INPUT_2):
            doc.run()
            assert doc.artifacts[-1].source == 'run'

        for doc in run_dexy_without_tempdir(CONFIG_WITH_INPUT_2):
            doc.run()
            assert doc.artifacts[-1].source == 'cache'
Пример #4
0
 def process(self):
     config = {}
     config['@input.'+ self.name + '|' + self.filter] = {
         "contents":self.content,
     }
     for doc in run_dexy_without_tempdir({".":config}):
         doc.run()
     return doc.output()
Пример #5
0
def test_config_multiple_directories():
    config = {
        "." : { "*.txt" : {} },
        "abc" : { "*.txt" : {} }
    }

    with tempdir():
        os.makedirs("abc")
        for filename in ["hello.txt", os.path.join("abc/hello.txt")]:
            with open(filename, "w") as f:
                f.write("hello")

        i = 0
        for doc in run_dexy_without_tempdir(config):
            i += 1
            doc.run()
            assert doc.output() == "hello"

        assert i == 2