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')))
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
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])
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)