From 8a2517d52d1190cf58436fb43fcc9e533fa03368 Mon Sep 17 00:00:00 2001 From: Michael C Ryan Date: Thu, 31 Oct 2024 09:51:51 -0400 Subject: [PATCH] Added better tests for ek80 checker functions. Added better tests for ek80 checker functions. --- echopype/tests/convert/test_convert_ek60.py | 3 +++ echopype/tests/convert/test_convert_ek80.py | 28 +++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/echopype/tests/convert/test_convert_ek60.py b/echopype/tests/convert/test_convert_ek60.py index 7909aa456..1a4c2f681 100644 --- a/echopype/tests/convert/test_convert_ek60.py +++ b/echopype/tests/convert/test_convert_ek60.py @@ -267,6 +267,7 @@ def test_converting_ek60_raw_with_missing_channel_power(): def test_is_EK60_ek60_files(): + """Check that EK60 files are identified as EK60""" # Collect all .raw files in the ek60 directory ek60_files = glob.glob("echopype/test_data/ek60/*.raw") @@ -275,6 +276,7 @@ def test_is_EK60_ek60_files(): assert is_EK60(test_file_path, storage_options={}) == True def test_is_EK60_er60_files(): + """Check that ER60 files are identified as EK60""" # Collect all .raw files in the ek60 directory (assuming ER60 files are also here) er60_files = glob.glob("echopype/test_data/ek60/*.raw") @@ -283,6 +285,7 @@ def test_is_EK60_er60_files(): assert is_EK60(test_file_path, storage_options={}) == True def test_is_EK60_non_ek60_files(): + """Check that non-EK60 files are not identified as EK60""" # Collect all .raw files in the ek80 directory (non-EK60 files) ek80_files = glob.glob("echopype/test_data/ek80/*.raw") diff --git a/echopype/tests/convert/test_convert_ek80.py b/echopype/tests/convert/test_convert_ek80.py index fe9001401..c76862c52 100644 --- a/echopype/tests/convert/test_convert_ek80.py +++ b/echopype/tests/convert/test_convert_ek80.py @@ -1,5 +1,5 @@ import shutil - +import glob import pytest import numpy as np import pandas as pd @@ -532,12 +532,20 @@ def test_parse_ek80_with_invalid_env_datagrams(): assert env_var.notnull().all() and env_var.dtype == np.float64 -def test_is_EK80_ek80_file(): - # Replace with the path to a valid EK80 test file that includes "configuration" - test_file_path = "echopype/test_data/ek80/D20170912-T234910.raw" - assert is_EK80(test_file_path, storage_options={}) == True - -def test_is_EK80_non_ek80_file(): - # Replace with the path to a test file without "configuration" key - test_file_path = "echopype/test_data/ek60/L0003-D20040909-T161906-EK60.raw" - assert is_EK80(test_file_path, storage_options={}) == False \ No newline at end of file +def test_is_EK80_ek80_files(): + """Test that EK80 files are identified as EK80.""" + # Collect all .raw files in the ek80 directory + ek80_files = glob.glob("echopype/test_data/ek80/*.raw") + + # Check that each file in ek80 is identified as EK80 + for test_file_path in ek80_files: + assert is_EK80(test_file_path, storage_options={}) == True + +def test_is_EK80_non_ek80_files(): + """Test that non-EK80 files are not identified as EK80.""" + # Collect all .raw files in the ek60 directory (non-EK80 files) + ek60_files = glob.glob("echopype/test_data/ek60/*.raw") + + # Check that each file in ek60 is not identified as EK80 + for test_file_path in ek60_files: + assert is_EK80(test_file_path, storage_options={}) == False \ No newline at end of file