예제 #1
0
def test_caching():
    with tempdir():
        wrapper1 = Wrapper()

        with open("abc.txt", "w") as f:
            f.write("these are the contents")

        doc1 = Doc("abc.txt|dexy", wrapper=wrapper1)
        wrapper1.docs = [doc1]
        wrapper1.run()

        assert isinstance(doc1.artifacts[0], InitialArtifact)
        hashstring_0_1 = doc1.artifacts[0].hashstring

        assert isinstance(doc1.artifacts[1], FilterArtifact)
        hashstring_1_1 = doc1.artifacts[1].hashstring

        wrapper2 = Wrapper()
        doc2 = Doc("abc.txt|dexy", wrapper=wrapper2)
        wrapper2.docs = [doc2]
        wrapper2.run()

        assert isinstance(doc2.artifacts[0], InitialArtifact)
        hashstring_0_2 = doc2.artifacts[0].hashstring

        assert isinstance(doc2.artifacts[1], FilterArtifact)
        hashstring_1_2 = doc2.artifacts[1].hashstring

        assert hashstring_0_1 == hashstring_0_2
        assert hashstring_1_1 == hashstring_1_2
예제 #2
0
def test_caching_virtual_file():
    with tempdir():
        wrapper1 = Wrapper()
        doc1 = Doc("abc.txt|dexy",
                contents = "these are the contents",
                wrapper=wrapper1)
        wrapper1.docs = [doc1]
        wrapper1.run()

        assert isinstance(doc1.artifacts[0], InitialVirtualArtifact)
        hashstring_0_1 = doc1.artifacts[0].hashstring

        assert isinstance(doc1.artifacts[1], FilterArtifact)
        hashstring_1_1 = doc1.artifacts[1].hashstring

        wrapper2 = Wrapper()
        doc2 = Doc(
                "abc.txt|dexy",
                contents = "these are the contents",
                wrapper=wrapper2)
        wrapper2.docs = [doc2]
        wrapper2.run()

        assert isinstance(doc2.artifacts[0], InitialVirtualArtifact)
        hashstring_0_2 = doc2.artifacts[0].hashstring

        assert isinstance(doc2.artifacts[1], FilterArtifact)
        hashstring_1_2 = doc2.artifacts[1].hashstring

        assert hashstring_0_1 == hashstring_0_2
        assert hashstring_1_1 == hashstring_1_2
예제 #3
0
def test_wrapper_run():
    with tempdir():
        wrapper = Wrapper()
        wrapper.setup_dexy_dirs()
        d1 = Doc("abc.txt|outputabc", contents="these are the contents", wrapper=wrapper)
        d2 = Doc("hello.txt|outputabc", contents="these are more contents", wrapper=wrapper)
        assert d1.state == 'setup'
        assert d2.state == 'setup'
        wrapper.docs = [d1, d2]
        wrapper.run()
        assert d1.state == 'complete'
        assert d2.state == 'complete'