created a feature flag, which disables the PORT_ADMINISTRATION validation rules. Currently, the flag is 'hardcoded' once in the library. Adapting the test to properly facilitate the feature flag
cherry picking the feature flag of 'port administration' rules
This commit is contained in:
parent
ba424b18b0
commit
d004e77650
4
.gitignore
vendored
4
.gitignore
vendored
@ -287,4 +287,6 @@ cython_debug/
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
#.idea/
|
||||
src/notebooks_metz/
|
||||
src/server/editable_requirements.txt
|
||||
|
||||
@ -54,6 +54,7 @@ class ValidationRuleBaseFunctions():
|
||||
self.sql_handler = sql_handler
|
||||
self.time_logic = TimeLogic()
|
||||
self.error_message_dict = error_message_dict
|
||||
self.ignore_port_administration_flag = True # flag: turn off all port administration validation rules
|
||||
|
||||
def describe_error_message(self, key)->str:
|
||||
"""
|
||||
@ -127,7 +128,10 @@ class ValidationRuleBaseFunctions():
|
||||
return violation_state
|
||||
|
||||
# filter by participant types of interest (agency, mooring, portauthority/administration, pilot, tug)
|
||||
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PORT_ADMINISTRATION.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
||||
if not self.ignore_port_administration_flag:
|
||||
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PORT_ADMINISTRATION.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
||||
else:
|
||||
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PORT_ADMINISTRATION.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
||||
df_times = df_times.loc[df_times["participant_type"].isin(participant_types),:]
|
||||
|
||||
# exclude missing entries and consider only pd.Timestamp entries (which ignores pd.NaT/null entries)
|
||||
@ -342,6 +346,9 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions):
|
||||
- Checks, if times_port_administration.eta_berth is filled in.
|
||||
- Measures the difference between 'now' and 'times_agency.eta_berth'.
|
||||
"""
|
||||
if self.ignore_port_administration_flag:
|
||||
return self.get_no_violation_default_output()
|
||||
|
||||
if not shipcall.type in [ShipcallType.INCOMING.value]:
|
||||
return self.get_no_violation_default_output()
|
||||
|
||||
@ -376,12 +383,8 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions):
|
||||
- Checks, if times_port_administration.etd_berth is filled in.
|
||||
- Measures the difference between 'now' and 'times_agency.etd_berth'.
|
||||
"""
|
||||
if not shipcall.type in [ShipcallType.OUTGOING.value, ShipcallType.SHIFTING.value]:
|
||||
return self.get_no_violation_default_output()
|
||||
|
||||
# check, if the header is filled in
|
||||
unassigned = self.sql_handler.check_if_any_participant_of_type_is_unassigned(shipcall, *[ParticipantType.AGENCY, ParticipantType.PORT_ADMINISTRATION])
|
||||
if unassigned:
|
||||
# check, if the header is filled in (agency & PORT_ADMINISTRATION)
|
||||
if (len(df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value]) != 1) or (len(df_times.loc[df_times["participant_type"]==ParticipantType.PORT_ADMINISTRATION.value]) != 1):
|
||||
return self.get_no_violation_default_output()
|
||||
|
||||
# preparation: obtain the correct times of the participant, define the query time and the key time
|
||||
|
||||
@ -343,8 +343,10 @@ def test_validation_rule_fct_missing_time_portadministration_berth_eta__shipcall
|
||||
# apply the validation rule
|
||||
(state, msg) = vr.validation_rule_fct_missing_time_portadministration_berth_eta(shipcall=shipcall, df_times=df_times)
|
||||
|
||||
# expectation: green state, no msg
|
||||
assert state==StatusFlags.YELLOW, f"function should return 'yellow', because the participant did not provide a time and the shipcall takes place soon (according to the agency)"
|
||||
if not vr.ignore_port_administration_flag:
|
||||
assert state==StatusFlags.YELLOW, f"function should return 'yellow', because the participant did not provide a time and the shipcall takes place soon (according to the agency)"
|
||||
else:
|
||||
assert state==StatusFlags.GREEN, f"function should return 'green', because the feature flag is set, which disables this validation rule"
|
||||
return
|
||||
|
||||
|
||||
@ -381,8 +383,10 @@ def test_validation_rule_fct_missing_time_portadministration_berth_etd__shipcall
|
||||
# apply the validation rule
|
||||
(state, msg) = vr.validation_rule_fct_missing_time_portadministration_berth_etd(shipcall=shipcall, df_times=df_times)
|
||||
|
||||
# expectation: green state, no msg
|
||||
assert state==StatusFlags.YELLOW, f"function should return 'yellow', because the participant did not provide a time and the shipcall takes place soon (according to the agency)"
|
||||
if not vr.ignore_port_administration_flag:
|
||||
assert state==StatusFlags.YELLOW, f"function should return 'yellow', because the participant did not provide a time and the shipcall takes place soon (according to the agency)"
|
||||
else:
|
||||
assert state==StatusFlags.GREEN, f"function should return 'green', because the ignore flag is set"
|
||||
return
|
||||
|
||||
def test_validation_rule_fct_missing_time_pilot_berth_eta__shipcall_soon_but_participant_estimated_time_undefined(build_sql_proxy_connection):
|
||||
@ -416,7 +420,7 @@ def test_validation_rule_fct_missing_time_pilot_berth_eta__shipcall_soon_but_par
|
||||
# apply the validation rule
|
||||
(state, msg) = vr.validation_rule_fct_missing_time_pilot_berth_eta(shipcall=shipcall, df_times=df_times)
|
||||
|
||||
# expectation: green state, no msg
|
||||
# expectation: yellow state
|
||||
assert state==StatusFlags.YELLOW, f"function should return 'yellow', because the participant did not provide a time and the shipcall takes place soon (according to the agency)"
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user