def test(): from snapflow_mailchimp import module as snapflow_mailchimp api_key = ensure_api_key() server = api_key.split("-")[ -1] # Hack? appears to be true for new api keys mailchimp = Client() mailchimp.set_config({ "api_key": api_key, "server": server, }) # delete_list(mailchimp, "9311ebcf06") list_id = create_test_list(mailchimp) try: g = graph() members_df = pd.DataFrame.from_records([ dict( email_address="*****@*****.**", status="subscribed", merge_fields={"f1": "v1"}, ), dict( email_address="*****@*****.**", status="subscribed", merge_fields={"f1": "v2"}, ), dict( email_address="*****@*****.**", status="subscribed", merge_fields={"f1": "v3"}, ), ]) # Initial graph import_df = g.create_node( "core.import_dataframe", params={ "dataframe": members_df, "schema": "MailchimpMember" }, ) export_aud = g.create_node( snapflow_mailchimp.functions.export_audience, input=import_df, params={ "api_key": api_key, "list_id": list_id, "server": server }, ) # logger.enable("snapflow") produce(export_aud, execution_timelimit_seconds=5, modules=[snapflow_mailchimp]) response = mailchimp.lists.get_list_members_info(list_id) assert len(response["members"]) == len(members_df) finally: delete_list(mailchimp, list_id)
def test_demo(): from snapflow_plotly import module as sf_plotly g = graph() # Initial graph node1 = g.create_node(sf_plotly.functions.plotly_demo, ) blocks = produce(node1, modules=[sf_plotly]) output = blocks[0] records = output.as_records() assert len(records) == 1 assert set(records[0].keys()) == set(["data", "layout"])
def test(): import {module} g = graph() # Initial graph node1 = g.create_node( {module}.snaps.Snap, params={"config_val": "val"}, ) output = produce(node1, modules=[{module}]) records = output.as_records() assert len(records) > 0
def test_overview(): from snapflow_stocks import module as stocks api_key = ensure_api_key() g = graph() # Initial graph overview = g.node( stocks.functions.alphavantage_import_company_overview, params={ "api_key": api_key, "tickers": ["AAPL"] }, ) blocks = produce(overview, execution_timelimit_seconds=1, modules=[stocks]) records = blocks[0].as_records() assert len(records) == 1
def test_tickers(): from snapflow_stocks import module as stocks api_key = ensure_api_key() g = graph() # Initial graph tickers = g.create_node( stocks.functions.marketstack_import_tickers, params={ "access_key": api_key, "exchanges": ["XNAS"] }, ) blocks = produce(tickers, execution_timelimit_seconds=1, modules=[stocks]) records = blocks[0].as_records() assert len(records) >= 100
def test_fred(): api_key = ensure_api_key() from snapflow_fred import module as fred env = Environment(metadata_storage="sqlite://") g = graph() # Initial graph gdp = g.create_node( "fred.import_observations", params={ "api_key": api_key, "series_id": "gdp" }, ) blocks = produce(gdp, env=env, modules=[fred]) records = blocks[0].as_records() assert len(records) >= (utcnow().year - 1946) * 4 - 1 assert len(records) < (utcnow().year + 1 - 1946) * 4 - 1