Skip to content

Commit

Permalink
Check folder instead of just folder name in path
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeldar committed Aug 29, 2023
1 parent ec7ffdb commit 948e644
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
22 changes: 11 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,25 @@ def create_product_from_file_path(file_path: str) -> Product:
timezone.utc
)

if "images" in file_path:
if "EO" in file_path:
if "images/" in file_path:
if "EO/" in file_path:
product = Product("image", "EO", last_modified_on)
if "HS" in file_path:
if "HS/" in file_path:
product = Product("image", "HS", last_modified_on)
if "IR" in file_path:
if "IR/" in file_path:
product = Product("image", "IR", last_modified_on)
elif "tactical" in file_path:
if "Detection" in file_path:
elif "tactical/" in file_path:
if "Detection/" in file_path:
product = Product("tactical", "Detection", last_modified_on)
if "HeatPerimeter" in file_path:
if "HeatPerimeter/" in file_path:
product = Product("tactical", "HeatPerimeter", last_modified_on)
if "IntenseHeat" in file_path:
if "IntenseHeat/" in file_path:
product = Product("tactical", "IntenseHeat", last_modified_on)
if "IsolatedHeat" in file_path:
if "IsolatedHeat/" in file_path:
product = Product("tactical", "IsolatedHeat", last_modified_on)
if "ScatteredHeat" in file_path:
if "ScatteredHeat/" in file_path:
product = Product("tactical", "ScatteredHeat", last_modified_on)
elif "videos" in file_path:
elif "videos/" in file_path:
product = Product("video", None, last_modified_on)

if product is None:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ def test_create_product_from_file_path_image(self, mock_getmtime):

mock_getmtime.assert_called_once_with(file_path)

@patch("os.path.getmtime", return_value=1234567890.0)
def test_create_product_from_file_path_image_with_wrong_type_in_path(
self, mock_getmtime
):
file_path = "images/EO/IRimage.tif"
expected_product = Product(
"image", "EO", datetime.fromtimestamp(1234567890.0, tz=timezone.utc)
)
created_product = create_product_from_file_path(file_path)
print(created_product)
print(expected_product)
self.assertEqual(created_product, expected_product)

mock_getmtime.assert_called_once_with(file_path)

@patch("os.path.getmtime", return_value=1234567890.0)
def test_create_product_from_file_path_tactical(self, mock_getmtime):
file_path = "tactical/Detection/some_detection.kml"
Expand Down

0 comments on commit 948e644

Please sign in to comment.