From 4b4a844acf18c0877e495aee4fcba3b2626d9b58 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Tue, 14 Dec 2021 21:02:35 -0500 Subject: [PATCH] add test asserting all derived tables have rows --- mimic-iv/tests/test_all_tables.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 mimic-iv/tests/test_all_tables.py diff --git a/mimic-iv/tests/test_all_tables.py b/mimic-iv/tests/test_all_tables.py new file mode 100644 index 000000000..befc81be4 --- /dev/null +++ b/mimic-iv/tests/test_all_tables.py @@ -0,0 +1,15 @@ +import pandas as pd +from pandas.io import gbq + +def test_tables_have_data(dataset, project_id, concepts): + """Verifies each table has data.""" + + for folder, concept_list in concepts.items(): + for concept_name in concept_list: + query = f""" + SELECT * + FROM {dataset}.{concept_name} + LIMIT 5 + """ + df = gbq.read_gbq(query, project_id=project_id, dialect="standard") + assert df.shape[0] > 0, f'did not find table for {folder}.{concept_name}'