Skip to content

Commit

Permalink
Merge pull request #55 from GSA/add-harvest-cli
Browse files Browse the repository at this point in the history
add arg parse function and test
  • Loading branch information
rshewitt authored Apr 24, 2024
2 parents fdf55ec + 3b5b4a1 commit c1fa24a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions harvester/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import json
import os
import argparse

import boto3
import sansjson
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "datagov-harvesting-logic"
version = "0.3.7"
version = "0.3.8"
description = ""
# authors = [
# {name = "Jin Sun", email = "[email protected]"},
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"

1 comment on commit c1fa24a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
harvester
   __init__.py50100% 
   ckan_utils.py4222 95%
   exceptions.py420100% 
   harvest.py4256565 85%
   logger_config.py10100% 
   utils.py6299 85%
TOTAL5777687% 

Tests Skipped Failures Errors Time
35 0 💤 0 ❌ 0 🔥 6.831s ⏱️

Please sign in to comment.