From 53142269b4895be26952c09a2aa265b63ccd8476 Mon Sep 17 00:00:00 2001 From: Reid Hewitt Date: Wed, 24 Apr 2024 09:49:53 -0600 Subject: [PATCH 1/2] add arg parse function and test --- harvester/utils.py | 11 +++++++++++ tests/unit/utils/test_utils.py | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/harvester/utils.py b/harvester/utils.py index 4f230c1f..3e31bf7b 100644 --- a/harvester/utils.py +++ b/harvester/utils.py @@ -1,6 +1,7 @@ import hashlib import json import os +import argparse import boto3 import sansjson @@ -11,6 +12,16 @@ # ruff: noqa: F841 +def parse_args(args): + + parser = argparse.ArgumentParser( + prog="Harvest Runner", description="etl harvest sources" + ) + parser.add_argument("-j", "--jobid") + + return parser.parse_args(args) + + def convert_set_to_list(obj): if isinstance(obj, set): return list(obj) diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 89fc438b..81ad049b 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -1,4 +1,5 @@ from harvester.ckan_utils import munge_tag, munge_title_to_name +from harvester.utils import parse_args import pytest # these tests are copied from @@ -44,3 +45,9 @@ def test_munge_title_to_name(self, original, expected): """Munge a list of names gives expected results.""" munge = munge_title_to_name(original) assert munge == expected + + +class TestGeneralUtils: + def test_args_parsing(self): + args = parse_args(["-j", "test-id"]) + assert args.jobid == "test-id" From 3b5b4a16ba0b474d5abf2e9a97c6c317121ec253 Mon Sep 17 00:00:00 2001 From: Reid Hewitt Date: Wed, 24 Apr 2024 09:52:30 -0600 Subject: [PATCH 2/2] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5e7b6d29..da451749 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "datagov-harvesting-logic" -version = "0.3.7" +version = "0.3.8" description = "" # authors = [ # {name = "Jin Sun", email = "jin.sun@gsa.gov"},