academic_observatory_workflows.pubmed_telescope.tests.test_pubmed_telescope

Module Contents

Classes

TestPubMedTelescope

Tests for the Pubmed telescope

TestPubMedUtils

Functions

query_table(→ List[Dict])

Query a BigQuery table, sorting the results and returning results as a list of dicts.

Attributes

FIXTURES_FOLDER

academic_observatory_workflows.pubmed_telescope.tests.test_pubmed_telescope.FIXTURES_FOLDER[source]
academic_observatory_workflows.pubmed_telescope.tests.test_pubmed_telescope.query_table(table_id: str, select_columns: str, order_by_field: str) List[Dict][source]

Query a BigQuery table, sorting the results and returning results as a list of dicts.

Parameters:
  • table_id – the table id.

  • select_columns – Columns to pull from the table.

  • order_by_field – what field or fields to order by.

Returns:

the table rows.

class academic_observatory_workflows.pubmed_telescope.tests.test_pubmed_telescope.TestPubMedTelescope(*args, **kwargs)[source]

Bases: observatory.platform.observatory_environment.ObservatoryTestCase

Tests for the Pubmed telescope

test_dag_structure()[source]

Test PubMed DAG structure.

test_dag_load()[source]

Test that the PubMed DAG can be loaded from a DAG bag.

test_telescope()[source]

Test the PubMed Telescope end to end

class academic_observatory_workflows.pubmed_telescope.tests.test_pubmed_telescope.TestPubMedUtils(*args, **kwargs)[source]

Bases: observatory.platform.observatory_environment.ObservatoryTestCase

test_download_datafiles()[source]

Test that an exmaple PubMed XMLs can be transformed successfully.

test_load_datafile()[source]

Test that a Pubmed datafile can be read in and parsed.

test_save_pubmed_jsonl()[source]

Test that data can be saved from to a json.gz or a .jsonl file correctly.

test_save_pubmed_merged_upserts()[source]

Test if records can be reliably pulled from transformed files and written to file.

test_parse_articles()[source]

Test if PubmedArticle records (upserts) can be pulled out from a data dictionary.

test_parse_deletes()[source]

Test if DeleteCiation records (deletes) can be pulled out from a data dictionary.

test_transform_pubmed()[source]

Test that exmaple PubMed XMLs can be transformed successfully.

test_merge_upserts_and_deletes()[source]
test_add_attributes()[source]

Test that attributes from the Biopython data classes can be reliably pulled out and added to the dictionary.

test_change_pubmed_list_structure()[source]

Test that the data in *list fields can be moved up one level to the parent field.

test_PubMedCustomEncoder()[source]

Test that files are written out as expected using the CustomEncoder for PubMed-like files.