diff --git a/src/server/BreCal/validators/validation_rule_functions.py b/src/server/BreCal/validators/validation_rule_functions.py index 591dfb8..80bb15d 100644 --- a/src/server/BreCal/validators/validation_rule_functions.py +++ b/src/server/BreCal/validators/validation_rule_functions.py @@ -500,7 +500,7 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): a certain threshold (e.g., 20 hours), a violation occurs 0001-L: - - Checks, if times_terminal.eta_berth is filled in. + - Checks, if times_terminal.operations_start is filled in. - Measures the difference between 'now' and 'times_agency.eta_berth'. """ # check, if the header is filled in (agency & terminal) @@ -512,7 +512,7 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): times_terminal = self.sql_handler.get_times_for_participant_type(df_times, participant_type=ParticipantType.TERMINAL.value) query_time = times_agency.eta_berth - key_time = times_terminal.eta_berth + key_time = times_terminal.operations_start # eta_berth does not exist in times_terminal! Instead, it is called operations_start threshold = ParticipantwiseTimeDelta.TERMINAL violation_state = self.check_time_delta_violation_query_time_to_now(query_time=query_time, key_time=key_time, threshold=threshold) @@ -530,7 +530,7 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): a certain threshold (e.g., 20 hours), a violation occurs 0001-M: - - Checks, if times_terminal.etd_berth is filled in. + - Checks, if times_terminal.operations_end is filled in. - Measures the difference between 'now' and 'times_agency.etd_berth'. """ # check, if the header is filled in (agency & terminal) @@ -542,7 +542,7 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): times_terminal = self.sql_handler.get_times_for_participant_type(df_times, participant_type=ParticipantType.TERMINAL.value) query_time = times_agency.etd_berth - key_time = times_terminal.etd_berth + key_time = times_terminal.operations_end # etd_berth does not exist in times_terminal! Instead, it is called operations_end threshold = ParticipantwiseTimeDelta.TERMINAL violation_state = self.check_time_delta_violation_query_time_to_now(query_time=query_time, key_time=key_time, threshold=threshold) @@ -850,7 +850,7 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): if shipcall.type in [ShipcallType.OUTGOING.value, ShipcallType.SHIFTING.value]: return (StatusFlags.GREEN, None) - violation_state = times_agency.pier_side!=times_terminal.pier_side + violation_state = bool(times_agency.pier_side)!=bool(times_terminal.pier_side) if violation_state: validation_name = inspect.currentframe().f_code.co_name diff --git a/src/server/tests/validators/test_validation_rule_functions.py b/src/server/tests/validators/test_validation_rule_functions.py index 3fccac5..cdb0183 100644 --- a/src/server/tests/validators/test_validation_rule_functions.py +++ b/src/server/tests/validators/test_validation_rule_functions.py @@ -367,7 +367,7 @@ def test_validation_rule_fct_missing_time_terminal_berth_eta__shipcall_soon_but_ df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value, "eta_berth"] = datetime.datetime.now() + datetime.timedelta(minutes=ParticipantwiseTimeDelta.TERMINAL-10) # set times agency to be undetermined - df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "eta_berth"] = None + df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "operations_start"] = None # previously: eta_berth, which does not exist in times_terminal # apply the validation rule (state, msg) = vr.validation_rule_fct_missing_time_terminal_berth_eta(shipcall=shipcall, df_times=df_times) @@ -389,7 +389,7 @@ def test_validation_rule_fct_missing_time_terminal_berth_etd__shipcall_soon_but_ df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value, "etd_berth"] = datetime.datetime.now() + datetime.timedelta(minutes=ParticipantwiseTimeDelta.TERMINAL-10) # set times agency to be undetermined - df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "etd_berth"] = None + df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "operations_end"] = None # previously: etd_berth, which does not exist in times_terminal # apply the validation rule (state, msg) = vr.validation_rule_fct_missing_time_terminal_berth_etd(shipcall=shipcall, df_times=df_times) @@ -820,6 +820,30 @@ def test_validation_rule_fct_agency_and_terminal_pier_side_disagreement__agency_ assert code==StatusFlags.YELLOW, f"status should be 'yellow', because agency and terminal do not agree on the selected pier side" return +def test_validation_rule_fct_agency_and_terminal_pier_side_disagreement__agency_and_terminal_disagree_terminal_is_none(build_sql_proxy_connection): + """0006-B validation_rule_fct_agency_and_terminal_pier_side_disagreement""" + vr = build_sql_proxy_connection['vr'] + shipcall = get_shipcall_simple() + df_times = get_df_times(shipcall) + df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value, "pier_side"] = True + df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "pier_side"] = None + + (code, msg) = vr.validation_rule_fct_agency_and_terminal_pier_side_disagreement(shipcall=shipcall, df_times=df_times) + assert code==StatusFlags.GREEN, f"status should be 'green', because the terminal's pier_side is not provided" + return + +def test_validation_rule_fct_agency_and_terminal_pier_side_disagreement__agency_and_terminal_disagree_terminal_is_nan(build_sql_proxy_connection): + """0006-B validation_rule_fct_agency_and_terminal_pier_side_disagreement""" + vr = build_sql_proxy_connection['vr'] + shipcall = get_shipcall_simple() + df_times = get_df_times(shipcall) + df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value, "pier_side"] = True + df_times.loc[df_times["participant_type"]==ParticipantType.TERMINAL.value, "pier_side"] = float("nan") + + (code, msg) = vr.validation_rule_fct_agency_and_terminal_pier_side_disagreement(shipcall=shipcall, df_times=df_times) + assert code==StatusFlags.GREEN, f"status should be 'yellow', because the terminal's pier_side is not provided" + return + def test_validation_rule_fct_agency_and_terminal_pier_side_agreement(build_sql_proxy_connection):