evanyeyeye / rainbow

Read chromatography and mass spectrometry binary files.
GNU General Public License v3.0
29 stars 15 forks source link

test_green Unit Test Date Format Mismatch #26

Open jlw387 opened 2 months ago

jlw387 commented 2 months ago

Hello!

I pip installed the library (version 1.0.9 according to pip list), cloned the repository, and ran the unit tests to make sure everything was installed correctly. One of the unit tests failed, and it seems like it is due to a date format mismatch.

Here is the printout I got for the "test_green" unit test (I have omitted some of my local paths with the <...> notation):

======================================================================
FAIL: test_green (tests.test_agilent.TestAgilent.test_green)
Tests a directory containing:
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\<...>\rainbow\tests\test_agilent.py", line 45, in test_green
    self._DataTester__test_data_directory("green", "D")
  File "C:\<...>\rainbow\tests\datatester.py", line 68, in __test_data_directory
    self.assertDictEqual(datadir.metadata, json_data['metadata'])
AssertionError: {'vendor': 'Agilent', 'date': '03-Feb-22, 11:22:20'} != {'vendor': 'Agilent', 'date': '3 Feb 22  11:22 am -0500'}
- {'date': '03-Feb-22, 11:22:20', 'vendor': 'Agilent'}
?           - ^   ^  ^      ^^

+ {'date': '3 Feb 22  11:22 am -0500', 'vendor': 'Agilent'}
?            ^   ^  ^      ^^^^^^^^

----------------------------------------------------------------------
Ran 17 tests in 39.398s

If it is relevant, I am on a Windows 11 computer with Python 3.11.5.

Based on my reading of the code, it looks like the metadata's date is being read from the .UV file instead of the .MS files, but the assert statement is expecting the date to match the .MS files' format. A simple fix to get the unit test to pass would be to adjust the date format in the metadata section of the unit test's "info.json" file, but if you actively want the metadata's date to be retrieved from the .MS files and not the .UV file, it may be worth filtering by file extension when setting it here:

https://github.com/evanyeyeye/rainbow/blob/21ce06b8d84bc10c3c9f2e2a6af61fc55c3882e2/rainbow/agilent/chemstation.py#L853-L854