Skip to content

Commit

Permalink
add arg parse function and test
Browse files Browse the repository at this point in the history
  • Loading branch information
rshewitt committed Apr 24, 2024
1 parent fdf55ec commit 5314226
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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
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 5314226

@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 🔥 5.135s ⏱️

Please sign in to comment.