Exemplo n.º 1
0
def test_run():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    if r.loaded():
        r.run()
        assert os.path.isfile(
            os.path.abspath(os.path.join(BASEDIR, '..',
                                         'example/csv.etl.csv')))
Exemplo n.º 2
0
def test_add_single_post_hook():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    if r.loaded():
        called = [False]

        def posthook(data):
            called[0] = True
            return True

        r.add_hook('post-etl', posthook)
        r.run()
    assert called
Exemplo n.º 3
0
def test_add_multi_post_hook():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    if r.loaded():
        called = [False for _ in range(3)]

        def posthook1(data):
            called[0] = True
            return True

        def posthook2(data):
            called[1] = True
            return True

        def posthook3(data):
            called[2] = True
            return True

        r.add_hook('post-etl', posthook1)
        r.add_hook('post-etl', posthook2)
        r.add_hook('post-etl', posthook3)
        r.run()
    assert (called[0] and called[1] and called[2])
Exemplo n.º 4
0
def test_pre_post_hook_order():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    if r.loaded():
        called = [0, 0]
        called_order = [0]

        def prehook(data):
            if called[0] == 0:
                called_order[0] += 1
                called[0] = called_order[0]
            return True

        def posthook(data):
            if called[1] == 0:
                called_order[0] += 1
                called[1] = called_order[0]
            return True

        r.add_hook('pre-etl', prehook)
        r.add_hook('post-etl', posthook)
        r.run()
    assert (called[0] == 1 and called[1] == 2)
Exemplo n.º 5
0
def test_description():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    assert (r.description() == 'Example Data Cleaning Task - CSV')
Exemplo n.º 6
0
def test_load_task():
    r = Araisan(
        os.path.abspath(os.path.join(BASEDIR, '..', 'example/csv.yaml')))
    assert r.loaded()