Skip to content

Commit

Permalink
Added test for dlis raw functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroKpaxo committed Sep 19, 2024
1 parent d6b81da commit 993bb35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions test/dlis/test_dlis_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

from dlisio import dlis

from wellbelog.belodlis.functions import unpack_physical_dlis, open_dlis_file

folder_path = Path(__file__).parent.parent / 'test_files'
file_path = folder_path / '1PIR1AL_conv_ccl_canhoneio.dlis'


def test_open_dlis_file():
physical_file = open_dlis_file(file_path)
assert isinstance(physical_file, dlis.PhysicalFile)
logical_files = unpack_physical_dlis(physical_file)
assert isinstance(logical_files, list)
assert len(logical_files) > 0
assert isinstance(logical_files[0], dlis.LogicalFile)
4 changes: 4 additions & 0 deletions test/dlis/test_dlis_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def test_search_files():
assert len(dlis_files) == 1
assert dlis_files[0].name == '1PIR1AL_conv_ccl_canhoneio.dlis'

# Testing the search_files method with a wrong path
dlis_files = dlis_processor.search_files(folder_path / 'wrong_path')
assert not len(dlis_files)


def test_read_dlis_file():
dlis_processor = DlisReader()
Expand Down
5 changes: 3 additions & 2 deletions wellbelog/belodlis/reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import pathlib
from typing import Optional

from dlisio.dlis import Frame

Expand Down Expand Up @@ -33,7 +34,7 @@ def load_raw(self, path_to_file: str, unpack=False) -> PhysicalFileModel:
return unpack_physical_dlis(file)
return file

def search_files(self, path: str) -> list[pathlib.Path]:
def search_files(self, path: str) -> Optional[list[pathlib.Path]]:
"""
Search for DLIS files in the given path and returns a list with the file paths.
Expand All @@ -47,7 +48,7 @@ def search_files(self, path: str) -> list[pathlib.Path]:
return dlis_files
except Exception as e:
self.logger.error(f'Error while searching for DLIS files: {e}')
return dlis_files
return None

Check warning on line 51 in wellbelog/belodlis/reader.py

View check run for this annotation

Codecov / codecov/patch

wellbelog/belodlis/reader.py#L51

Added line #L51 was not covered by tests

def process_physical_file(self, path: str, folder_name: str = None) -> PhysicalFileModel:
"""
Expand Down

0 comments on commit 993bb35

Please sign in to comment.