Skip to content

Commit

Permalink
fixup test
Browse files Browse the repository at this point in the history
  • Loading branch information
sstruzik committed Jan 29, 2025
1 parent 8b533d5 commit 2653b02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion ods_tools/oed/oed_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ def is_valid_value(value, valid_ranges, allow_blanks):
Returns:
True if value is in one of the range
"""

if value in BLANK_VALUES:
return allow_blanks
for valid_range in valid_ranges:
Expand Down
4 changes: 0 additions & 4 deletions ods_tools/oed/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ def from_stream_obj(cls, exposure, oed_type, stream_obj, format=None, read_param
oed_df = cls.as_oed_type(oed_df, column_to_field)
oed_df = cls.prepare_df(oed_df, column_to_field, ods_fields)

# TODO: here find the class of business and check required column

# apply the filters to the dataframe
for fn in oed_source.filters:
oed_df = fn(oed_df)
Expand Down Expand Up @@ -306,7 +304,6 @@ def prepare_df(cls, df, column_to_field, ods_fields):
for col, field_info in column_to_field.items():
fill_empty(df, col, OedSchema.get_default_from_ods_fields(ods_fields, field_info['Input Field Name']))

# TODO: allow blank is no longer, required column check need to be done differently
# add required columns that allow blank values if missing
present_field = set(field_info['Input Field Name'] for field_info in column_to_field.values())
for field_info in ods_fields.values():
Expand Down Expand Up @@ -392,7 +389,6 @@ def load_dataframe(self, version_name=None):
read_params = {'keep_default_na': False,
'na_values': PANDAS_DEFAULT_NULL_VALUES.difference({'NA'})}
read_params.update(source.get('read_param', {}))
print(filepath)
oed_df = self.read_csv(filepath, self.exposure.get_input_fields(self.oed_type), filter=self.filters, **read_params)
else:
raise Exception(f"Source type {source['source_type']} is not supported")
Expand Down
13 changes: 8 additions & 5 deletions tests/test_ods_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def test_oed_cyber_example(self):
oed_example_url = "https://raw.githubusercontent.com/OasisLMF/ODS_OpenExposureData/refs/heads/main/Examples"
config = {
'account': oed_example_url + '/cyber_account.csv',
'oed_schema_info': '/home/sstruzik/tests/OED_V4/OpenExposureData_Spec.json',
'check_oed': True,
'check_oed': True, # issue with current marine exemple set to true and remove the correction when fixed
'use_field': True,
}
assert OedExposure(**config).class_of_business == ClassOfBusiness.cyb
Expand All @@ -149,17 +148,21 @@ def test_oed_marinecargo_example(self):
config = {
'location': oed_example_url + '/marinecargo_location.csv',
'account': oed_example_url + '/marinecargo_account.csv',
'oed_schema_info': '/home/sstruzik/tests/OED_V4/OpenExposureData_Spec.json',
'check_oed': True,
'check_oed': False, # issue with current marine exemple set to true and remove the correction when fixed
'use_field': True,
}
## marine example manual fixup ###
exposure = OedExposure(**config)
exposure.account.dataframe["PolDedType6All"] = 1
config['account'] = exposure.account.dataframe
config['check_oed'] = True
#####
assert OedExposure(**config).class_of_business in [ClassOfBusiness.prop, ClassOfBusiness.mar]

def test_oed_liability_example(self):
oed_example_url = "https://raw.githubusercontent.com/OasisLMF/ODS_OpenExposureData/refs/heads/main/Examples"
config = {
'account': oed_example_url + '/liability_account.csv',
'oed_schema_info': '/home/sstruzik/tests/OED_V4/OpenExposureData_Spec.json',
'check_oed': True,
'use_field': True,
}
Expand Down

0 comments on commit 2653b02

Please sign in to comment.