diff --git a/.gitignore b/.gitignore index e9aea06..d2ea58d 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,7 @@ ENV/ env.sh config.json .autoenv.zsh -*~ \ No newline at end of file +*~ + +*config.json +*catalog.json \ No newline at end of file diff --git a/tap_appsflyer/__init__.py b/tap_appsflyer/__init__.py index 3b44808..e96e891 100644 --- a/tap_appsflyer/__init__.py +++ b/tap_appsflyer/__init__.py @@ -36,6 +36,16 @@ } +def clean_config(config: dict) -> dict: + """Strips whitespace from any values in the config.""" + for key in config.keys(): + value = config[key] + if isinstance(value, str): + config[key] = value.strip() + + return config + + def af_datetime_str_to_datetime(s): return datetime.datetime.strptime(s.strip(), "%Y-%m-%d %H:%M:%S") @@ -595,7 +605,8 @@ def main(): "api_token" ]) - CONFIG.update(args.config) + config = clean_config(args.config) + CONFIG.update(config) if args.state: STATE.update(args.state) diff --git a/tests/unittests/test_helpers.py b/tests/unittests/test_helpers.py index 8674fd6..e64c8d3 100644 --- a/tests/unittests/test_helpers.py +++ b/tests/unittests/test_helpers.py @@ -1,7 +1,7 @@ import datetime from unittest.mock import patch -from tap_appsflyer import get_restricted_start_date +from tap_appsflyer import clean_config, get_restricted_start_date MOCKED_DATE = datetime.datetime(2021, 7, 1, 1, 1, 1, 369251) @@ -22,3 +22,17 @@ def test_get_restricted_start_date(): date = get_restricted_start_date(test_case['case']) assert date == test_case['expected'] + + +def test_clean_config(): + test_cases = [ + {'case': {'app_id': ' 123456789 '}, 'expected': '123456789'}, + {'case': {'app_id': '7898901 '}, 'expected': '7898901'}, + {'case': {'app_id': ' 90234-0823jsjfsfsuf'}, 'expected': '90234-0823jsjfsfsuf'}, + {'case': {'app_id': 'fajslfaw084578fsdfj'}, 'expected': 'fajslfaw084578fsdfj'}, + {'case': {'app_id': ' abc def ghi '}, 'expected': 'abc def ghi'}, + ] + + for test_case in test_cases: + config = clean_config(test_case['case']) + assert config['app_id'] == test_case['expected']