From 947093b180e4403ab46b2d7550dce114e61da10c Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Fri, 22 Dec 2023 12:11:28 -0700 Subject: [PATCH] docs: standardize descriptions for a consistent API Standardize function descriptions for API clarity and consistency. --- src/gbif_registrar/_utilities.py | 101 ++++++++++++++----------------- src/gbif_registrar/configure.py | 51 ++++++++++++---- src/gbif_registrar/register.py | 59 +++++++++--------- src/gbif_registrar/upload.py | 18 +++--- src/gbif_registrar/validate.py | 15 ++--- tests/test__utilities.py | 5 +- tests/test_configure.py | 21 ++++--- tests/test_register.py | 14 +++-- tests/test_upload.py | 4 +- 9 files changed, 158 insertions(+), 130 deletions(-) diff --git a/src/gbif_registrar/_utilities.py b/src/gbif_registrar/_utilities.py index 1539c77..c3836d7 100644 --- a/src/gbif_registrar/_utilities.py +++ b/src/gbif_registrar/_utilities.py @@ -1,4 +1,4 @@ -"""Utility functions FOR INTERNAL USE ONLY!""" +"""Utility functions for internal use only.""" from os import environ import json @@ -14,8 +14,7 @@ def _check_completeness(registrations): """Checks registrations for completeness. A complete registration has values for all fields except (perhaps) - `synchronized`, which is not essential for initiating a GBIF - crawl. + `synchronized`, which is not essential for uploading to GBIF. Parameters ---------- @@ -44,7 +43,7 @@ def _check_group_registrations(registrations): """Checks uniqueness of dataset group registrations. Registrations can be part of a group, the most recent of which is - considered to be the authoratative version of the series. + considered to be the authoritative version of the series. Parameters ---------- @@ -95,7 +94,7 @@ def _check_synchronized(registrations): def _check_local_dataset_group_id_format(registrations): - """Check the format of the local_dataset_group_id. + """Checks the format of the local_dataset_group_id. registrations : pandas.DataFrame A dataframe of the registrations file. Use`_read_registrations_file` to @@ -152,7 +151,7 @@ def _check_local_dataset_id(registrations): def _check_local_dataset_id_format(registrations): - """Check the format of the local_dataset_id. + """Checks the format of the local_dataset_id. Parameters ---------- @@ -211,7 +210,7 @@ def _check_local_endpoints(registrations): def _check_one_to_one_cardinality(data, col1, col2): - """Check for one-to-one cardinality between two columns of a dataframe. + """Checks for one-to-one cardinality between two columns of a dataframe. This is a helper function used in a couple registration checks. @@ -247,7 +246,7 @@ def _check_one_to_one_cardinality(data, col1, col2): def _delete_local_dataset_endpoints(gbif_dataset_uuid): - """Delete all local dataset endpoints from a GBIF dataset. + """Deletes all local dataset endpoints from a GBIF dataset. Parameters ---------- @@ -261,8 +260,8 @@ def _delete_local_dataset_endpoints(gbif_dataset_uuid): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ # Get the list of existing endpoints to delete endpoints = get( @@ -287,7 +286,13 @@ def _delete_local_dataset_endpoints(gbif_dataset_uuid): def _expected_cols(): - """Expected columns of the registrations file""" + """Returns expected columns of the registrations file. + + Returns + ------- + list + The expected columns of the registrations file. + """ cols = [ "local_dataset_id", "local_dataset_group_id", @@ -299,15 +304,15 @@ def _expected_cols(): def _get_gbif_dataset_uuid(local_dataset_group_id, registrations): - """Return the gbif_dataset_uuid value. + """Returns the gbif_dataset_uuid value. Parameters ---------- local_dataset_group_id : str - The dataset group identifier in the EDI repository. Has the format: - {scope}.{identifier}. + The dataset group identifier in the EDI repository. registrations : pandas dataframe - The registrations file as a dataframe. + The registrations file as a dataframe. Use the _read_registrations_file + function to create this. Returns @@ -316,14 +321,7 @@ def _get_gbif_dataset_uuid(local_dataset_group_id, registrations): The gbif_dataset_uuid value. This is the UUID assigned by GBIF to the local dataset group identifier. A new value will be returned if a gbif_dataset_uuid value doesn't already exist for a - local_dataset_group_id. - - Notes - ----- - The local_dataset_group_id and gbif_dataset_uuid values have a one-to-one - relationship because this allows a dataset series (i.e. multiple versions - of a dataset) to be registered with GBIF as a single dataset and displayed - from a single URL endpoint on the GBIF system. + local_dataset_group_id in the registrations file. """ # Look in the registrations dataframe to see if there is a matching # local_data_set_group_id value, and if it has a non-empty @@ -354,13 +352,12 @@ def _get_gbif_dataset_uuid(local_dataset_group_id, registrations): def _get_local_dataset_endpoint(local_dataset_id): - """Return the local_dataset_endpoint value. + """Returns the local_dataset_endpoint value. Parameters ---------- local_dataset_id : str - The dataset identifier in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The dataset identifier in the EDI repository. Returns ------- @@ -370,8 +367,8 @@ def _get_local_dataset_endpoint(local_dataset_id): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ scope = local_dataset_id.split(".")[0] identifier = local_dataset_id.split(".")[1] @@ -389,13 +386,12 @@ def _get_local_dataset_endpoint(local_dataset_id): def _get_local_dataset_group_id(local_dataset_id): - """Return the local_dataset_group_id value. + """Returns the local_dataset_group_id value. Parameters ---------- local_dataset_id : str - The dataset identifier in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The dataset identifier in the EDI repository. Returns ------- @@ -409,13 +405,12 @@ def _get_local_dataset_group_id(local_dataset_id): def _is_synchronized(local_dataset_id, registrations_file): - """Check if a local dataset is synchronized with the GBIF registry. + """Checks if a local dataset is synchronized with the GBIF registry. Parameters ---------- local_dataset_id : str - The identifier of the dataset in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The identifier of the dataset in the EDI repository. registrations_file : str Path of the registrations file. @@ -458,7 +453,7 @@ def _is_synchronized(local_dataset_id, registrations_file): def _post_local_dataset_endpoint(local_dataset_endpoint, gbif_dataset_uuid): - """Post a local dataset endpoint to GBIF. + """Posts a local dataset endpoint to GBIF. Parameters ---------- @@ -466,7 +461,7 @@ def _post_local_dataset_endpoint(local_dataset_endpoint, gbif_dataset_uuid): This is the URL for downloading the dataset (.zip archive) at the EDI repository. Use the _get_local_dataset_endpoint function in the utilities module to obtain this value. - gbif_dataset_uuid : str + gbif_dataset_uuid : str The registration identifier assigned by GBIF to the local dataset group. @@ -477,8 +472,8 @@ def _post_local_dataset_endpoint(local_dataset_endpoint, gbif_dataset_uuid): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ my_endpoint = {"url": local_dataset_endpoint, "type": "DWC_ARCHIVE"} resp = post( @@ -492,13 +487,12 @@ def _post_local_dataset_endpoint(local_dataset_endpoint, gbif_dataset_uuid): def _post_new_metadata_document(local_dataset_id, gbif_dataset_uuid): - """Post a new metadata document to GBIF. + """Posts a new metadata document to GBIF. Parameters ---------- local_dataset_id : str - The identifier of the dataset in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The identifier of the dataset in the EDI repository. gbif_dataset_uuid : str The registration identifier assigned by GBIF to the local dataset group. @@ -510,8 +504,8 @@ def _post_new_metadata_document(local_dataset_id, gbif_dataset_uuid): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ metadata = _read_local_dataset_metadata(local_dataset_id) resp = post( @@ -525,7 +519,7 @@ def _post_new_metadata_document(local_dataset_id, gbif_dataset_uuid): def _read_gbif_dataset_metadata(gbif_dataset_uuid): - """Read the metadata of a GBIF dataset. + """Reads the metadata of a GBIF dataset. Parameters ---------- @@ -541,8 +535,8 @@ def _read_gbif_dataset_metadata(gbif_dataset_uuid): ----- This is high-level metadata, not the full EML document. - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ resp = requests.get(url=environ["GBIF_API"] + "/" + gbif_dataset_uuid, timeout=60) if resp.status_code != 200: @@ -558,8 +552,7 @@ def _read_local_dataset_metadata(local_dataset_id): Parameters ---------- local_dataset_id : str - The identifier of the dataset in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The identifier of the dataset in the EDI repository. Returns ------- @@ -568,8 +561,8 @@ def _read_local_dataset_metadata(local_dataset_id): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ # Build URL for metadata document to be read metadata_url = ( @@ -590,7 +583,7 @@ def _read_local_dataset_metadata(local_dataset_id): def _read_registrations_file(registrations_file): - """Return the registrations file as a Pandas dataframe. + """Returns the registrations file as a Pandas dataframe. Parameters ---------- @@ -617,7 +610,7 @@ def _read_registrations_file(registrations_file): def _request_gbif_dataset_uuid(): - """Request a GBIF dataset UUID value from GBIF. + """Requests a GBIF dataset UUID value from GBIF. Returns ------- @@ -627,8 +620,8 @@ def _request_gbif_dataset_uuid(): Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ title = "Placeholder title, to be written over by EML metadata from EDI" data = { diff --git a/src/gbif_registrar/configure.py b/src/gbif_registrar/configure.py index 0985b36..73871a1 100644 --- a/src/gbif_registrar/configure.py +++ b/src/gbif_registrar/configure.py @@ -1,23 +1,28 @@ -"""Initialize the gbif_registrar package.""" +"""Configure the gbif_registrar package for use.""" + from json import load, dump from os import environ def load_configuration(configuration_file): - """Authenticates the user with the GBIF API and sets other global - environment variables for use by the gbif_registrar package. + """Loads the configuration file as global environment variables for use + by the gbif_registrar functions. - To remove these environment variables, use the unload_configuration function. + Remove these environment variables with the unload_configuration function. Parameters ---------- configuration_file : str - Path of the configuration file. Create this file using the - write_configuration function. + Path of the configuration file. Returns ------- None + + Notes + ----- + Create a template configuration file with the initialize_configuration_file + function. """ with open(configuration_file, "r", encoding="utf-8") as config: config = load(config) @@ -26,7 +31,8 @@ def load_configuration(configuration_file): def unload_configuration(): - """Removes global environment variables set by the load_configuration function. + """Removes global environment variables set by the load_configuration + function. Returns ------- @@ -46,18 +52,41 @@ def unload_configuration(): del environ[key] -def write_configuration(file_path): - """Write the template configuration to file. +def initialize_configuration_file(file_path): + """Returns a template configuration file to path. + + The template configuration contains all the parameters a user needs to set + up the gbif_registrar package for use. Parameters ---------- file_path : str - Path to the configuration file. + Path to which the configuration file will be written. Returns ------- None - Writes the configuration file to disk. + Writes the template configuration file to disk as a .json file. + + Notes + ----- + The configuration file is a .json file with the following keys: + USER_NAME : str + The username for the GBIF account. + PASSWORD : str + The password for the GBIF account. + ORGANIZATION : str + The organization key for the GBIF account. + INSTALLATION : str + The installation key for the GBIF account. + GBIF_API : str + The GBIF API endpoint. + REGISTRY_BASE_URL : str + The GBIF registry base URL. + GBIF_DATASET_BASE_URL : str + The GBIF dataset base URL. + PASTA_ENVIRONMENT : str + The PASTA environment base URL. """ configuration = { "USER_NAME": "ws_client_demo", diff --git a/src/gbif_registrar/register.py b/src/gbif_registrar/register.py index 30a9a85..9ef0f06 100644 --- a/src/gbif_registrar/register.py +++ b/src/gbif_registrar/register.py @@ -1,4 +1,5 @@ -"""Functions for registering datasets with GBIF.""" +"""Register datasets with GBIF.""" + import os.path import tempfile import pandas as pd @@ -11,22 +12,21 @@ ) -def initialize_registrations_file(path): - """Returns an empty registrations file. +def initialize_registrations_file(file_path): + """Returns a template registrations file to path. The registrations file maps datasets from the local EDI data repository to - the remote GBIF registry and indicates synchronization status between the - two. + the remote GBIF registry. Parameters ---------- - path : str + file_path : str Path of file to be written. A .csv file extension is expected. Returns ------- None - The registrations file as a .csv. + Writes the template registrations file to disk as a .csv. Notes ----- @@ -34,7 +34,8 @@ def initialize_registrations_file(path): - `local_dataset_id`: The dataset identifier in the EDI repository. This is the primary key. The term 'dataset' used here, is synonymous with the - term 'data package' in the EDI repository. + term 'data package' in the EDI repository. Values in this column have + the format: {scope}.{identifier}.{revision}. - `local_dataset_group_id`: The dataset group identifier in the EDI repository. This often forms a one-to-many relationship with `local_dataset_id`. The term 'dataset group' used here, is synonymous @@ -45,7 +46,7 @@ def initialize_registrations_file(path): - `gbif_dataset_uuid`: The registration identifier assigned by GBIF to the `local_dataset_group_id`. This forms a one-to-one relationship with `local_dataset_group_id`. - - `is_synchronized`: The synchronization status of the `local_dataset_id` + - `synchronized`: The synchronization status of the `local_dataset_id` with GBIF. Is `True` if the local dataset is synchronized with GBIF, and `False` if the local dataset is not synchronized with GBIF. This forms a one-to-one relationship with `local_dataset_id`. @@ -54,33 +55,33 @@ def initialize_registrations_file(path): -------- >>> initialize_registrations_file("registrations.csv") """ - if os.path.exists(path): + if os.path.exists(file_path): pass else: data = pd.DataFrame(columns=_expected_cols()) - data.to_csv(path, index=False, mode="x") + data.to_csv(file_path, index=False, mode="x") def register_dataset(local_dataset_id, registrations_file): - """Register a local dataset with GBIF and add it to the registrations file. + """Registers a local dataset with GBIF and adds it to the registrations + file. Parameters ---------- local_dataset_id : str - The dataset identifier in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The local dataset identifier. registrations_file : str The path of the registrations file. Returns ------- None - The registrations file, written back to `registrations` as a .csv. + The registrations file, written back to itself as a .csv. Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the configure module to do this. Examples -------- @@ -114,37 +115,37 @@ def register_dataset(local_dataset_id, registrations_file): def complete_registration_records(registrations_file, local_dataset_id=None): - """Return a completed set of registration records. + """Returns a completed set of registration records. - This function can be run to repair one or more registrations that have - missing values in the local_dataset_group_id, local_dataset_endpoint, or - gbif_dataset_uuid columns. + This function can be run to repair one or more dataset registrations that + have incomplete information in the local_dataset_group_id, + local_dataset_endpoint, or gbif_dataset_uuid columns. Parameters ---------- registrations_file : str The path of the registrations file. local_dataset_id : str, optional - The dataset identifier in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. If provided, only the registration - record for the local_dataset_id will be completed. If not provided, - all registration records with missing values will be completed. + The dataset identifier in the EDI repository. If provided, only the + registration record for the specified `local_dataset_id` will be + completed. If not provided, all registration records with incomplete + information will be repaired. Returns ------- None - The registrations file, written back to `registrations` as a .csv. + The registrations file, written back to itself as a .csv. Notes ----- - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the configure module to do this. Examples -------- >>> # Complete all registration records with missing values. >>> complete_registration_records("registrations.csv") - >>> # Complete the registration record for the local_dataset_id. + >>> # Repair the registration record for a specific dataset. >>> complete_registration_records("registrations.csv", "edi.929.2") """ registrations = _read_registrations_file(registrations_file) diff --git a/src/gbif_registrar/upload.py b/src/gbif_registrar/upload.py index 18677ad..e91a20f 100644 --- a/src/gbif_registrar/upload.py +++ b/src/gbif_registrar/upload.py @@ -1,4 +1,4 @@ -"""Functions for calling a GBIF crawl.""" +"""Upload datasets to GBIF.""" from os import environ from time import sleep @@ -6,20 +6,19 @@ def upload_dataset(local_dataset_id, registrations_file): - """Upload a local dataset to GBIF. + """Upload a dataset to GBIF. Parameters ---------- local_dataset_id : str - The identifier of the dataset in the EDI repository. Has the format: - {scope}.{identifier}.{revision}. + The identifier of a dataset in the EDI repository. registrations_file : str Path of the registrations file. Returns ------- None - The registrations file as a .csv. + The registrations file written back to itself as a .csv. Notes ----- @@ -27,11 +26,10 @@ def upload_dataset(local_dataset_id, registrations_file): file. The status is True if the dataset was successfully synchronized with GBIF and False otherwise. - Print messages indicate the progress of the upload process. The messages - are written to the standard output stream (stdout). + Print messages indicate the progress of the upload process. - This function requires authentication with GBIF. Use the load_configuration function - from the authenticate module to do this. + This function requires authentication with GBIF. Use the load_configuration + function from the authenticate module to do this. """ print(f"Uploading {local_dataset_id} to GBIF.") @@ -111,7 +109,7 @@ def upload_dataset(local_dataset_id, registrations_file): _utilities._post_new_metadata_document(local_dataset_id, gbif_dataset_uuid) print(f"Posted new metadata document for {local_dataset_id} to GBIF.") - # Run the is_synchronized function until a True value is returned or the + # Run the _is_synchronized function until a True value is returned or the # max number of attempts is reached. synchronized = False max_attempts = 12 # Average synchronization time is 20 seconds diff --git a/src/gbif_registrar/validate.py b/src/gbif_registrar/validate.py index 2957b3d..310c2e3 100644 --- a/src/gbif_registrar/validate.py +++ b/src/gbif_registrar/validate.py @@ -1,4 +1,4 @@ -"""A module for validating the registrations file""" +"""Validate the dataset registrations file.""" from gbif_registrar.register import _read_registrations_file from gbif_registrar._utilities import _check_completeness @@ -11,16 +11,17 @@ def validate_registrations(registrations_file): - """Validates the registrations file. + """Validates the dataset registrations file. - This is a wrapper to `_check_completeness`, `_check_local_dataset_id`, - `_check_group_registrations`, `_check_local_endpoints`, and - `_check_synchronized`. + This function validates the dataset registrations file by checking for + completeness, local dataset ID format, group registrations, local + endpoints, and synchronization status. If any issues are found, a warning + is raised. Parameters ---------- registrations_file : str or pathlike object - Path of the registrations file. + Path of the dataset registrations file. Returns ------- @@ -29,7 +30,7 @@ def validate_registrations(registrations_file): Warns ----- UserWarning - If registration issues are found. + Warnings are issued if registration issues are found. Examples -------- diff --git a/tests/test__utilities.py b/tests/test__utilities.py index fbf4ae8..929bb05 100644 --- a/tests/test__utilities.py +++ b/tests/test__utilities.py @@ -1,4 +1,4 @@ -"""Test utilities""" +"""Test the _utilities.py module.""" from os import environ import warnings @@ -262,7 +262,8 @@ def test_get_gbif_dataset_uuid_exists(registrations): def test_get_gbif_dataset_uuid_does_not_exist(registrations, mocker): """Test that the _get_gbif_dataset_uuid function gets a new GBIF dataset - UUID when the local dataset group ID does not have a GBIF dataset UUID.""" + UUID when the local dataset group ID does not yet have a GBIF dataset + UUID.""" # Mock the response from _get_gbif_dataset_uuid, so we don't have to make # an actual HTTP request. gbif_dataset_uuid = "a_new_gbif_dataset_uuid" diff --git a/tests/test_configure.py b/tests/test_configure.py index 9dc93b2..fdccb3b 100644 --- a/tests/test_configure.py +++ b/tests/test_configure.py @@ -1,16 +1,17 @@ -"""Test init.py""" +"""Test the configure.py module""" from json import load from os import environ from gbif_registrar.configure import ( load_configuration, unload_configuration, - write_configuration, + initialize_configuration_file, ) def test_load_configuration_creates_environmental_varaiables(): - """Test that the load_configuration function creates global environment variables.""" + """Test that the load_configuration function creates the expected set of + global environment variables.""" load_configuration("tests/test_config.json") assert environ["USER_NAME"] == "ws_client_demo" assert environ["PASSWORD"] == "Demo123" @@ -20,12 +21,12 @@ def test_load_configuration_creates_environmental_varaiables(): assert environ["REGISTRY_BASE_URL"] == "https://registry.gbif-uat.org/dataset" assert environ["GBIF_DATASET_BASE_URL"] == "https://www.gbif-uat.org/dataset" assert environ["PASTA_ENVIRONMENT"] == "https://pasta-s.lternet.edu" - # Clean up the environment variables. - unload_configuration() + unload_configuration() # clean up after the test def test_unload_configuration_removes_environmental_variables(): - """Test that the unload_configuration function removes global environment variables.""" + """Test that the unload_configuration function removes the expected set of + global environment variables.""" load_configuration("tests/test_config.json") unload_configuration() assert "USER_NAME" not in environ @@ -38,10 +39,10 @@ def test_unload_configuration_removes_environmental_variables(): assert "PASTA_ENVIRONMENT" not in environ -def test_write_configuration(tmp_path): - """Test that the write_configuration function writes a json file with the - expected keys.""" - write_configuration(tmp_path / "test_config.json") +def test_initialize_configuration_file(tmp_path): + """Test that the initialize_configuration_file function writes a json file + with the expected keys.""" + initialize_configuration_file(tmp_path / "test_config.json") with open(tmp_path / "test_config.json", "r", encoding="utf-8") as config: config = load(config) assert "USER_NAME" in config diff --git a/tests/test_register.py b/tests/test_register.py index f35c1a3..3166aad 100644 --- a/tests/test_register.py +++ b/tests/test_register.py @@ -1,4 +1,4 @@ -"""Test register_dataset.py""" +"""Test the register.py module""" import os.path import hashlib @@ -116,7 +116,8 @@ def test_complete_registration_records_handles_empty_dataframe( def test_initialize_registrations_file_does_not_overwrite(tmp_path): - """Does not overwrite.""" + """Test that the initialize_registrations_file function does not overwrite + an existing registrations file.""" file = tmp_path / "registrations.csv" initialize_registrations_file(file) with open(file, "rb") as registrations: @@ -127,7 +128,8 @@ def test_initialize_registrations_file_does_not_overwrite(tmp_path): def test_initialize_registrations_file_has_expected_columns(tmp_path): - """Has expected columns.""" + """Test that the initialize_registrations_file function creates a + registrations file with the expected columns.""" file = tmp_path / "registrations.csv" initialize_registrations_file(file) data = pd.read_csv(file, delimiter=",") @@ -136,14 +138,16 @@ def test_initialize_registrations_file_has_expected_columns(tmp_path): def test_initialize_registrations_file_writes_to_path(tmp_path): - """File is written to path.""" + """Test that the initialize_registrations_file function writes a + registrations file to the specified path.""" file = tmp_path / "registrations.csv" initialize_registrations_file(file) assert os.path.exists(file) def test_read_registrations_reads_file(): - """Reads the file.""" + """Test that the _read_registrations_file function reads the registrations + file.""" registrations = _read_registrations_file("tests/registrations.csv") assert isinstance(registrations, pd.DataFrame) diff --git a/tests/test_upload.py b/tests/test_upload.py index de46940..4b87f64 100644 --- a/tests/test_upload.py +++ b/tests/test_upload.py @@ -1,4 +1,4 @@ -"""Test upload.py""" +"""Test the upload.py module.""" from re import search import pytest @@ -12,7 +12,7 @@ def assert_successful_upload(captured, tmp_path, local_dataset_id): """Declare test assertions that are shared for both the 'new' and - 'updated' dataset cases, and works for both real and mocked HTTP + 'updated' dataset test cases, and works for both real and mocked HTTP requests.""" # Check the std out for the expected print statements. pattern = "Uploading .+ to GBIF."