From fe8a95338fd0da4d8cd0f9d62be5722066f18d2c Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Mon, 11 Sep 2023 09:22:09 +0530 Subject: [PATCH 01/12] fixed typecasting error --- tap_marketo/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tap_marketo/client.py b/tap_marketo/client.py index 49f268f..f7abcff 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -26,7 +26,7 @@ # Marketo limits REST requests to 50000 per day with a rate limit of 100 # calls per 20 seconds. # http://developers.marketo.com/rest-api/ -MAX_DAILY_CALLS = int(50000 * 0.8) +MAX_DAILY_CALLS = 50000 * 0. RATE_LIMIT_CALLS = 100 RATE_LIMIT_SECONDS = 20 @@ -80,7 +80,7 @@ def raise_for_rate_limit(data): class Client: # pylint: disable=unused-argument def __init__(self, endpoint, client_id, client_secret, - max_daily_calls=MAX_DAILY_CALLS, + max_daily_calls=None, user_agent=DEFAULT_USER_AGENT, job_timeout=JOB_TIMEOUT, poll_interval=POLL_INTERVAL, @@ -89,7 +89,7 @@ def __init__(self, endpoint, client_id, client_secret, self.domain = extract_domain(endpoint) self.client_id = client_id self.client_secret = client_secret - self.max_daily_calls = int(max_daily_calls) + self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS)) self.user_agent = user_agent self.job_timeout = job_timeout self.poll_interval = poll_interval From fa818ec9cb181d575b100457258fb32b4b178d2b Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:06:02 +0530 Subject: [PATCH 02/12] fixed linting issue --- tap_marketo/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tap_marketo/client.py b/tap_marketo/client.py index f7abcff..e10d22a 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -26,7 +26,7 @@ # Marketo limits REST requests to 50000 per day with a rate limit of 100 # calls per 20 seconds. # http://developers.marketo.com/rest-api/ -MAX_DAILY_CALLS = 50000 * 0. +MAX_DAILY_CALLS = 50000 * 0.8 RATE_LIMIT_CALLS = 100 RATE_LIMIT_SECONDS = 20 @@ -89,7 +89,7 @@ def __init__(self, endpoint, client_id, client_secret, self.domain = extract_domain(endpoint) self.client_id = client_id self.client_secret = client_secret - self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS)) + self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS) self.user_agent = user_agent self.job_timeout = job_timeout self.poll_interval = poll_interval From 6a1ee0f86e1ea4d47da4ba64bd8ad7318b0a8457 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:38:23 +0530 Subject: [PATCH 03/12] added test for max_api_limit --- tap_marketo/client.py | 8 ++++- tests/test_client_max_api_limit.py | 57 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/test_client_max_api_limit.py diff --git a/tap_marketo/client.py b/tap_marketo/client.py index e10d22a..1d69c0e 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -89,7 +89,13 @@ def __init__(self, endpoint, client_id, client_secret, self.domain = extract_domain(endpoint) self.client_id = client_id self.client_secret = client_secret - self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS) + try: + self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS) + except (ValueError, TypeError): + # Raises TypeError for None / Null Value + # Raises ValueError for "" / bool value + self.max_daily_calls = int(MAX_DAILY_CALLS) + self.user_agent = user_agent self.job_timeout = job_timeout self.poll_interval = poll_interval diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py new file mode 100644 index 0000000..e5476f5 --- /dev/null +++ b/tests/test_client_max_api_limit.py @@ -0,0 +1,57 @@ +import unittest +from datetime import datetime,timedelta +from tap_marketo.client import Client, MAX_DAILY_CALLS + +class TestDateWindowConfig(unittest.TestCase): + + def test_datewindow_disabled_no_val(self): + """ + Verify that daily_calls_limit is default if no value is passed + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT'}) + + self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) + + def test_datewindow_disabled_empty_str(self): + """ + Verify that daily_calls_limit is default if empty string value is passed + Verify no Exception is raised for typecasting error between str to num + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":""}) + + self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) + + def test_datewindow_disabled_bool_val(self): + """ + Verify that daily_calls_limit is default if bool value is passed + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':False}) + self.assertEqual(client.max_daily_calls ,MAX_DAILY_CALLS) + + def test_datewindow_disabled_num_val(self): + """ + Verify that api_limit is 0 if 0 value is passed + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":0}) + self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) + + def test_datewindow_disabled_none_val(self): + """ + Verify that api_limit is default if None value is passed + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":None}) + self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) + + def test_datewindow_enabled_num_val(self): + """ + Verify that api_limit is set appropriately if num value is passed + """ + # Initialize Client object + client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":3}) + + self.assertEqual(client.max_daily_calls, 3) \ No newline at end of file From b5571b2ef5173bcd5b861f96863fd07093ebde08 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:42:16 +0530 Subject: [PATCH 04/12] added readme and changelog --- CHANGELOG.md | 3 +++ setup.py | 2 +- tests/test_client_max_api_limit.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69b1b5f..f9a8632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2.5.1 + * Fixed Validation Error for `max_daily_calls` [#84](https://github.com/singer-io/tap-marketo/pull/84) + ## 2.5.0 * Add campaignId field to activities streams [#82](https://github.com/singer-io/tap-marketo/pull/82) diff --git a/setup.py b/setup.py index 6914127..1870f19 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='tap-marketo', - version='2.5.0', + version='2.5.1', description='Singer.io tap for extracting data from the Marketo API', author='Stitch', url='http://singer.io', diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index e5476f5..0766bad 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -54,4 +54,4 @@ def test_datewindow_enabled_num_val(self): # Initialize Client object client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":3}) - self.assertEqual(client.max_daily_calls, 3) \ No newline at end of file + self.assertEqual(client.max_daily_calls, 3) From dfca3b3af08615e18906a046a083b34341780134 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Wed, 13 Sep 2023 09:57:49 +0530 Subject: [PATCH 05/12] updated unit test --- tap_marketo/client.py | 1 + tests/test_client_max_api_limit.py | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tap_marketo/client.py b/tap_marketo/client.py index 1d69c0e..e47d2e7 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -95,6 +95,7 @@ def __init__(self, endpoint, client_id, client_secret, # Raises TypeError for None / Null Value # Raises ValueError for "" / bool value self.max_daily_calls = int(MAX_DAILY_CALLS) + singer.log_critical(f"Invalid Value passed for max_daily_calls :{max_daily_calls}, using default value {self.max_daily_calls}") self.user_agent = user_agent self.job_timeout = job_timeout diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index 0766bad..0dde33a 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -1,21 +1,20 @@ import unittest -from datetime import datetime,timedelta from tap_marketo.client import Client, MAX_DAILY_CALLS -class TestDateWindowConfig(unittest.TestCase): +class TestmaxdailycallsConfig(unittest.TestCase): - def test_datewindow_disabled_no_val(self): + def test_maxdailycalls_default_no_val(self): """ - Verify that daily_calls_limit is default if no value is passed + Verify that max_daily_calls is default if no value is passed """ # Initialize Client object client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT'}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) - def test_datewindow_disabled_empty_str(self): + def test_maxdailycalls_default_empty_str(self): """ - Verify that daily_calls_limit is default if empty string value is passed + Verify that max_daily_calls is default if empty string value is passed Verify no Exception is raised for typecasting error between str to num """ # Initialize Client object @@ -23,15 +22,15 @@ def test_datewindow_disabled_empty_str(self): self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) - def test_datewindow_disabled_bool_val(self): + def test_maxdailycalls_default_bool_val(self): """ - Verify that daily_calls_limit is default if bool value is passed + Verify that max_daily_calls is default if bool value is passed """ # Initialize Client object client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':False}) self.assertEqual(client.max_daily_calls ,MAX_DAILY_CALLS) - def test_datewindow_disabled_num_val(self): + def test_maxdailycalls_default_num_val(self): """ Verify that api_limit is 0 if 0 value is passed """ @@ -39,7 +38,7 @@ def test_datewindow_disabled_num_val(self): client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":0}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) - def test_datewindow_disabled_none_val(self): + def test_maxdailycalls_default_none_val(self): """ Verify that api_limit is default if None value is passed """ @@ -47,7 +46,7 @@ def test_datewindow_disabled_none_val(self): client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":None}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) - def test_datewindow_enabled_num_val(self): + def test_maxdailycalls_enabled_num_val(self): """ Verify that api_limit is set appropriately if num value is passed """ From 02c2cbdb2b2e77aa5206e50973dfc97fedb11253 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Wed, 13 Sep 2023 23:53:49 +0530 Subject: [PATCH 06/12] updated scenarios --- tap_marketo/client.py | 10 ++++---- tests/test_client_max_api_limit.py | 38 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tap_marketo/client.py b/tap_marketo/client.py index e47d2e7..0ba9e0b 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -91,11 +91,11 @@ def __init__(self, endpoint, client_id, client_secret, self.client_secret = client_secret try: self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS) - except (ValueError, TypeError): - # Raises TypeError for None / Null Value - # Raises ValueError for "" / bool value - self.max_daily_calls = int(MAX_DAILY_CALLS) - singer.log_critical(f"Invalid Value passed for max_daily_calls :{max_daily_calls}, using default value {self.max_daily_calls}") + if self.max_daily_calls <= 0: + raise ValueError("Limit Cannot be Negative or Zero") + except (ValueError, TypeError) as err: + singer.log_critical(f"Invalid Value passed for max_daily_calls: {max_daily_calls}") + raise err self.user_agent = user_agent self.job_timeout = job_timeout diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index 0dde33a..da32599 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -32,7 +32,7 @@ def test_maxdailycalls_default_bool_val(self): def test_maxdailycalls_default_num_val(self): """ - Verify that api_limit is 0 if 0 value is passed + Verify that api_limit is default if 0 value is passed """ # Initialize Client object client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":0}) @@ -54,3 +54,39 @@ def test_maxdailycalls_enabled_num_val(self): client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":3}) self.assertEqual(client.max_daily_calls, 3) + + def test_maxdailycalls_failed_comma_val(self): + """ + Verify that exception is raised if invalid input value is passed + """ + params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"30,000"} + # Initialize Client object + with self.assertRaises(ValueError): + Client(**params) + + def test_maxdailycalls_failed_decimal_val(self): + """ + Verify that api_limit is set appropriately if num value is passed + """ + # Initialize Client object + params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"3700.15"} + with self.assertRaises(ValueError): + Client(**params) + + def test_maxdailycalls_failed_negative_val(self): + """ + Verify that api_limit is set appropriately if num value is passed + """ + # Initialize Client object + params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"-522"} + with self.assertRaises(ValueError): + Client(**params) + + def test_maxdailycalls_default_str_zero_val(self): + """ + Verify that api_limit is default if "0" value is passed + """ + # Initialize Client object + params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"0"} + with self.assertRaises(ValueError): + Client(**params) \ No newline at end of file From ff78422d1ccb46a28cbaa59994f822f3c5adddde Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:10:22 +0530 Subject: [PATCH 07/12] updated tap-tester image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e7df668..2a5f9b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:tap-tester + - image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:stitch-tap-tester steps: - checkout - run: From d3055f629a6fc8807d721cff9dd80653bf2387d0 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:13:58 +0530 Subject: [PATCH 08/12] fixed pylint ignores --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a5f9b2..cef8ca1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: name: 'Pylint' command: | source ~/.virtualenvs/tap-marketo/bin/activate - pylint tap_marketo -d C,R + pylint tap_marketo -d C,R,W - run: name: 'JSON Validator' command: | From 54f17feb65b3e39a2ed33a53c145bf5b2321ecb2 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:37:25 +0530 Subject: [PATCH 09/12] updated schema validator --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cef8ca1..f78282d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,7 @@ jobs: name: 'JSON Validator' command: | source /usr/local/share/virtualenvs/tap-tester/bin/activate - stitch-validate-json ~/.virtualenvs/tap-marketo/lib/python3.5/site-packages/tap_marketo/schemas/*.json + stitch-validate-json tap_marketo/schemas/*.json - run: name: 'Unit Tests' command: | From 90b01ef6bd735fca8180b99add32dbd04593f4e0 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:15:12 +0530 Subject: [PATCH 10/12] added ut for true value --- tap_marketo/client.py | 2 +- tests/test_client_max_api_limit.py | 47 +++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/tap_marketo/client.py b/tap_marketo/client.py index 0ba9e0b..de0291d 100644 --- a/tap_marketo/client.py +++ b/tap_marketo/client.py @@ -91,7 +91,7 @@ def __init__(self, endpoint, client_id, client_secret, self.client_secret = client_secret try: self.max_daily_calls = int(max_daily_calls or MAX_DAILY_CALLS) - if self.max_daily_calls <= 0: + if self.max_daily_calls <= 1: raise ValueError("Limit Cannot be Negative or Zero") except (ValueError, TypeError) as err: singer.log_critical(f"Invalid Value passed for max_daily_calls: {max_daily_calls}") diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index da32599..71b06c3 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -8,7 +8,7 @@ def test_maxdailycalls_default_no_val(self): Verify that max_daily_calls is default if no value is passed """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT'}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT'}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) @@ -18,7 +18,7 @@ def test_maxdailycalls_default_empty_str(self): Verify no Exception is raised for typecasting error between str to num """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":""}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':''}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) @@ -27,15 +27,28 @@ def test_maxdailycalls_default_bool_val(self): Verify that max_daily_calls is default if bool value is passed """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':False}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':False}) self.assertEqual(client.max_daily_calls ,MAX_DAILY_CALLS) - def test_maxdailycalls_default_num_val(self): + def test_maxdailycalls_bool_true_val(self): + """ + Verify that max_daily_calls is default if bool value is passed + """ + # Initialize Client object + params = {'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':True} + with self.assertRaises(ValueError): + try: + Client(**params) + except Exception as err: + self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + raise err + + def test_maxdailycalls_default_zero_val(self): """ Verify that api_limit is default if 0 value is passed """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":0}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':0}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) def test_maxdailycalls_default_none_val(self): @@ -43,7 +56,7 @@ def test_maxdailycalls_default_none_val(self): Verify that api_limit is default if None value is passed """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":None}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':None}) self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) def test_maxdailycalls_enabled_num_val(self): @@ -51,7 +64,7 @@ def test_maxdailycalls_enabled_num_val(self): Verify that api_limit is set appropriately if num value is passed """ # Initialize Client object - client = Client(**{'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":3}) + client = Client(**{'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':3}) self.assertEqual(client.max_daily_calls, 3) @@ -59,7 +72,7 @@ def test_maxdailycalls_failed_comma_val(self): """ Verify that exception is raised if invalid input value is passed """ - params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"30,000"} + params = {'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':'30,000'} # Initialize Client object with self.assertRaises(ValueError): Client(**params) @@ -69,7 +82,7 @@ def test_maxdailycalls_failed_decimal_val(self): Verify that api_limit is set appropriately if num value is passed """ # Initialize Client object - params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"3700.15"} + params = {'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':'3700.15'} with self.assertRaises(ValueError): Client(**params) @@ -78,15 +91,23 @@ def test_maxdailycalls_failed_negative_val(self): Verify that api_limit is set appropriately if num value is passed """ # Initialize Client object - params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"-522"} + params = {'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':'-522'} with self.assertRaises(ValueError): - Client(**params) + try: + Client(**params) + except Exception as err: + self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + raise err def test_maxdailycalls_default_str_zero_val(self): """ Verify that api_limit is default if "0" value is passed """ # Initialize Client object - params = {'endpoint': "123-ABC-789",'client_id':'ABC-123','client_secret':'123-QRT',"max_daily_calls":"0"} + params = {'endpoint': '123-ABC-789','client_id':'ABC-123','client_secret':'123-QRT','max_daily_calls':'0'} with self.assertRaises(ValueError): - Client(**params) \ No newline at end of file + try: + Client(**params) + except Exception as err: + self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + raise err \ No newline at end of file From ba0cb35cdc87a33dca375c4886da0be9674a46d9 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:17:49 +0530 Subject: [PATCH 11/12] updated __str__ usage --- tests/test_client_max_api_limit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index 71b06c3..b49f6c6 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -22,7 +22,7 @@ def test_maxdailycalls_default_empty_str(self): self.assertEqual(client.max_daily_calls, MAX_DAILY_CALLS) - def test_maxdailycalls_default_bool_val(self): + def test_maxdailycalls_default_bool_false_val(self): """ Verify that max_daily_calls is default if bool value is passed """ @@ -40,7 +40,7 @@ def test_maxdailycalls_bool_true_val(self): try: Client(**params) except Exception as err: - self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + self.assertEqual(str(err),"Limit Cannot be Negative or Zero") raise err def test_maxdailycalls_default_zero_val(self): @@ -96,7 +96,7 @@ def test_maxdailycalls_failed_negative_val(self): try: Client(**params) except Exception as err: - self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + self.assertEqual(str(err),"Limit Cannot be Negative or Zero") raise err def test_maxdailycalls_default_str_zero_val(self): @@ -109,5 +109,5 @@ def test_maxdailycalls_default_str_zero_val(self): try: Client(**params) except Exception as err: - self.assertEqual(err.__str__(),"Limit Cannot be Negative or Zero") + self.assertEqual(str(err),"Limit Cannot be Negative or Zero") raise err \ No newline at end of file From bb3488854cc7567a2d1494ca4055983f4c218f09 Mon Sep 17 00:00:00 2001 From: VishalP <20889199+Vi6hal@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:18:23 +0530 Subject: [PATCH 12/12] added eof line --- tests/test_client_max_api_limit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client_max_api_limit.py b/tests/test_client_max_api_limit.py index b49f6c6..51ac50d 100644 --- a/tests/test_client_max_api_limit.py +++ b/tests/test_client_max_api_limit.py @@ -110,4 +110,4 @@ def test_maxdailycalls_default_str_zero_val(self): Client(**params) except Exception as err: self.assertEqual(str(err),"Limit Cannot be Negative or Zero") - raise err \ No newline at end of file + raise err