Skip to content

Commit a80e9ca

Browse files
author
Alex Meadows
committed
process_tracker_python-124 Add Extract Tracker finder
Added check and test for if process_tracking_id is not provided, then need to ensure that process_name and process_type are not None. Had to provide default values as a result of adding in the process_tracking_id instantiation.
1 parent 98324d0 commit a80e9ca

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

process_tracker/process_tracker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ def __init__(
153153
self.logger.error(error_msg)
154154
raise Exception(error_msg)
155155
else:
156+
if process_name is None or process_type is None:
157+
error_msg = "process_name and process_type must be set."
158+
self.logger.error(error_msg)
159+
raise Exception(error_msg)
156160

157161
self.actor = self.data_store.get_or_create_item(
158162
model=Actor, actor_name=actor_name

tests/test_process_tracker.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,9 +1674,6 @@ def test_raise_run_error_with_fail(self):
16741674
fail_date,
16751675
]
16761676

1677-
print(self.provided_end_date)
1678-
print(process[0].last_failed_run_date_time)
1679-
16801677
expected_result = [
16811678
self.process_tracker.process_status_failed,
16821679
self.provided_end_date,
@@ -2169,3 +2166,19 @@ def test_determine_process_targets(self):
21692166
expected_targets = self.process_tracker.targets
21702167

21712168
return expected_targets == given_targets
2169+
2170+
def test_ensure_nulls_caught_on_instantiation(self):
2171+
"""
2172+
With the adding of the ability of have a process_tracking_id we have to allow for nulled values for process_name
2173+
and process_type. If ProcessTracker is instantiated with either (or both) being null, an exception should be
2174+
raised.
2175+
:return:
2176+
"""
2177+
2178+
with self.assertRaises(Exception) as context:
2179+
2180+
ProcessTracker()
2181+
2182+
return self.assertTrue(
2183+
"process_name and process_type must be set." in str(context.exception)
2184+
)

0 commit comments

Comments
 (0)