From b7056a258a1ac2d402490a6c3cae502928c13eb4 Mon Sep 17 00:00:00 2001 From: Charlotte Kostelic Date: Wed, 30 Oct 2024 14:49:45 -0400 Subject: [PATCH] Readme updates (#9) * updated readme * added vendor check to validate_vendor_files --- README.md | 8 ++++---- tests/test_cli.py | 12 ++++++++++++ vendor_file_cli/__init__.py | 6 ++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ac1d52..9bac397 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ CLI tool to retrieve files from vendor servers. ## Usage ``` -$ fetch all-available-records +$ fetch all-vendor-files ``` -This project provides a command line interface to connect to and retrieve files from vendors using FTP/SFTP. Files are copied to the vendor's directory on BookOps' NSDROP SFTP server. +This project provides a command line interface to connect to and retrieve files from vendors using FTP/SFTP. Files are copied to the vendor's directory on BookOps' NSDROP SFTP server. Credentials are read from a local `yaml` file or environment variables. This CLI can also validate MARC records using the models defined in [record-validator](https://github.com/BookOps-CAT/record-validator). Currently this tool is able to validate records for Eastview, Leila, and Amalivre (SASB). @@ -36,7 +36,7 @@ The following information is also available using `validator --help` ##### Retrieve all new files `$ fetch all-vendor-files` -Reads credentials for all vendor servers from a `yaml` file. Retrieves all new files for all vendors with credentials in the `yaml` file. +Retrieves all new files for all vendors with configured credentials. - Logs into each vendor's server, - Creates a lists of files on the server and in the corresponding directory on NSDROP, - Copies all files from the vendor's server that are not in the NSDROP directory, @@ -47,7 +47,7 @@ Reads credentials for all vendor servers from a `yaml` file. Retrieves all new f ##### List all vendors configured to work with CLI `$ fetch available-vendors` -Reads the local `yaml` config file and prints the list of vendors who are configured to work with the CLI. +Prints a list of vendors with credentials configured to work with the CLI. ##### Validate vendor .mrc files `$ fetch validate-file` diff --git a/tests/test_cli.py b/tests/test_cli.py index c4731db..40c6d05 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -83,3 +83,15 @@ def test_vendor_file_cli_validate_vendor_files(cli_runner, caplog): assert result.exit_code == 0 assert "(NSDROP) Connecting to " in caplog.text assert "(NSDROP) Validating eastview file: foo.mrc" in caplog.text + + +def test_vendor_file_cli_validate_vendor_files_invalid_vendor(cli_runner, caplog): + result = cli_runner.invoke( + cli=vendor_file_cli, + args=["validate-file", "-v", "foo", "-f", "foo.mrc"], + ) + assert result.exit_code == 0 + assert ( + "Vendor not supported for validation." + "Only EASTVIEW, LEILA, and AMALIVRE_SASB supported." in result.stdout + ) diff --git a/vendor_file_cli/__init__.py b/vendor_file_cli/__init__.py index 6b4b396..3a5f2b1 100644 --- a/vendor_file_cli/__init__.py +++ b/vendor_file_cli/__init__.py @@ -81,6 +81,12 @@ def validate_vendor_files(vendor: str, file: str) -> None: Returns: None """ + if vendor.upper() not in ["EASTVIEW", "LEILA", "AMALIVRE_SASB"]: + click.echo( + "Vendor not supported for validation." + "Only EASTVIEW, LEILA, and AMALIVRE_SASB supported." + ) + return validate_files(vendor=vendor, files=[file])