Exemplo n.º 1
0
def run_stripe_test(api_key: str):
    from snapflow_stripe import module as stripe

    if not api_key:
        api_key = TEST_API_KEY
    storage = get_tmp_sqlite_db_url()
    env = Environment(DataspaceCfg(metadata_storage="sqlite://", storages=[storage]))
    env.add_module(stripe)

    # Initial graph
    raw_charges = GraphCfg(
        key="import_charges",
        function="stripe.import_charges",
        params={"api_key": api_key},
    )
    clean_charges = GraphCfg(
        key="clean_charges", function="stripe.clean_charges", input="import_charges"
    )
    g = GraphCfg(nodes=[raw_charges, clean_charges])
    results = env.produce(
        clean_charges.key, g, target_storage=storage, execution_timelimit_seconds=1
    )
    records = results[0].stdout().as_records()
    assert len(records) >= 100
    assert records[0]["amount"] > 0
Exemplo n.º 2
0
def test_bigcommerce_order_products():
    from snapflow_bigcommerce import module as snapflow_bigcommerce

    env = Environment(metadata_storage="sqlite://")
    env.add_module(snapflow_bigcommerce)

    g = graph()

    # Initial graph
    api_key = ensure_api_key()
    store_id = ensure_store_id()
    get_orders = g.create_node(
        snapflow_bigcommerce.functions.import_order_products,
        params={"api_key": api_key, "store_id": store_id,},
    )

    blocks = env.produce(get_orders, g, execution_timelimit_seconds=2,)
    assert len(blocks[0].as_records()) > 0
Exemplo n.º 3
0
def run_test_crunchbase_import_funding_rounds(user_key):
    from snapflow_crunchbase import module as snapflow_crunchbase

    env = Environment()
    env.add_module(snapflow_crunchbase)
    env.add_storage("file://.")
    g = graph()

    # test funding rounds importer
    import_funding_rounds = g.create_node(
        snapflow_crunchbase.functions.import_funding_rounds,
        params={
            "user_key": user_key,
            "use_sample": True
        },
    )
    output = env.produce(node_like=import_funding_rounds, graph=g)
    assert len(output[0].as_dataframe()) == 50