pytroll / pytroll-collectors

Collector modules for Pytroll
GNU General Public License v3.0
3 stars 18 forks source link

region collector never finishes if start_time after end_time (probably stuck in infinite loop) #82

Open gerritholl opened 3 years ago

gerritholl commented 3 years ago

When the end time for a granule is before the start time, the region collector is apparently supposed to do something clever, judging from this code block:

https://github.com/pytroll/pytroll-collectors/blob/7cb0d488f67618fbbcb835a42817b0cdf7473ce8/pytroll_collectors/region_collector.py#L84-L91

However, I've tried to write a unit test for this, see #77 or

https://github.com/gerritholl/pytroll-collectors/blob/1ad53748b5b2c267f6513a13a1cb5d6b23cfc50c/pytroll_collectors/tests/test_region_collector.py

where this unit test never finishes, apparently stuck in an infinite loop:

@unittest.mock.patch("pyorbital.tlefile.urlopen", new=_fakeopen)
def test_faulty_end_time(europe_collector, caplog):
    """Test adapting if end_time before start_time."""
    granule_metadata = {
        "platform_name": "Metop-C",
        "sensor": "avhrr",
        "start_time": datetime.datetime(2021, 4, 11, 0, 0),
        "end_time": datetime.datetime(2021, 4, 10, 23, 58)}
    with caplog.at_level(logging.DEBUG):
        europe_collector(granule_metadata)
    assert "Adjusted end time" in caplog.text

which I suspect to be either one of those two:

https://github.com/pytroll/pytroll-collectors/blob/7cb0d488f67618fbbcb835a42817b0cdf7473ce8/pytroll_collectors/region_collector.py#L170-L187