Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract conditions and packages #257

Merged
merged 114 commits into from
May 14, 2024
Merged

Conversation

DeltaDaniel
Copy link
Contributor

No description provided.

@DeltaDaniel DeltaDaniel linked an issue May 8, 2024 that may be closed by this pull request
@DeltaDaniel DeltaDaniel removed a link to an issue May 8, 2024
src/kohlrahbi/ahbtable/ahbcondtions.py Outdated Show resolved Hide resolved
src/kohlrahbi/ahbtable/ahbcondtions.py Outdated Show resolved Hide resolved
src/kohlrahbi/ahbtable/ahbcondtions.py Outdated Show resolved Hide resolved
src/kohlrahbi/ahbtable/ahbcondtions.py Show resolved Hide resolved
src/kohlrahbi/ahbtable/ahbpackagetable.py Outdated Show resolved Hide resolved
src/kohlrahbi/conditions/command.py Show resolved Hide resolved
src/kohlrahbi/read_functions.py Outdated Show resolved Hide resolved
src/kohlrahbi/read_functions.py Outdated Show resolved Hide resolved
Comment on lines +66 to +85
@freeze_time("2024-04-29")
def test_save_pruefi_map_to_toml(self):
"""
test save_pruefi_map_to_toml.
"""
pruefis = {
"29001": "file1.docx",
"17201": "file2.docx",
"37001": "file3.docx",
}
save_pruefi_map_to_toml(pruefis, "FV1910")
expected_output_path = (
Path(__file__).parents[1] / "src" / "kohlrahbi" / "cache" / "FV1910_pruefi_docx_filename_map.toml"
)
assert expected_output_path.exists()
expected_pruefi_map = '[meta_data]\nupdated_on = 2024-04-29\n\n[pruefidentifikatoren]\n29001 = "file1.docx"\n17201 = "file2.docx"\n37001 = "file3.docx"\n'
with open(expected_output_path, "r", encoding="utf-8") as f:
actual_pruefi_map = f.read()
assert actual_pruefi_map == expected_pruefi_map
expected_output_path.unlink()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this test as the coverage was complaining. 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove all the toml related code, because we do not use the toml pruefi map anymore.
Or am I wrong here? ^^

Copy link
Contributor Author

@DeltaDaniel DeltaDaniel May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact we used in at two instances, one unsued fct (removed now in 34d1164). The other function scans all pruefis and write the pruefi to file map to the cache which again is used in get_pruefi_to_file_mapping in

def get_pruefi_to_file_mapping(basic_input_path: Path, format_version: EdifactFormatVersion) -> dict[str, str]:
"""Returns the pruefi to file mapping. If the cache file does not exist, it creates it."""
default_path_to_cache_file = Path(__file__).parents[1] / "cache" / f"{format_version}_pruefi_docx_filename_map.toml"
if default_path_to_cache_file.exists():
pruefi_to_file_mapping_cache = load_pruefi_docx_file_map_from_file(default_path_to_cache_file)
pruefi_to_file_mapping = pruefi_to_file_mapping_cache.get("pruefidentifikatoren")
if isinstance(pruefi_to_file_mapping, type(None)):
raise ReferenceError(f"Could not find pruefidentifikatoren in {default_path_to_cache_file}")
return dict(pruefi_to_file_mapping)
path_to_docx_files = basic_input_path / Path(f"edi_energy_de/{format_version}")
pruefi_to_file_mapping = find_pruefidentifikatoren(path_to_docx_files)
save_pruefi_map_to_toml(pruefi_to_file_mapping, format_version.value)
return pruefi_to_file_mapping
🤔

unittests/test_ahb_table.py Outdated Show resolved Hide resolved
DeltaDaniel and others added 21 commits May 13, 2024 10:14
@DeltaDaniel DeltaDaniel merged commit 715c179 into main May 14, 2024
10 checks passed
@DeltaDaniel DeltaDaniel deleted the DDB/flavour_extract_conditions branch May 14, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cover the case if two package tables of two different formats are in one AHB document
2 participants