Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test failures #201

Merged
merged 10 commits into from
Feb 29, 2024
26 changes: 13 additions & 13 deletions trollflow2/tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ def setUp(self):
def test_run_does_not_call_process_directly(self):
"""Test that process is called through Process."""
from trollflow2.launcher import Runner
with mock.patch('trollflow2.launcher.yaml.load'),\
mock.patch('trollflow2.launcher.open'),\
mock.patch('trollflow2.launcher.generate_messages') as generate_messages,\
mock.patch('trollflow2.launcher.process') as process,\
mock.patch('trollflow2.launcher.check_results'),\
with mock.patch('trollflow2.launcher.yaml.load'), \
mock.patch('trollflow2.launcher.open'), \
mock.patch('trollflow2.launcher.generate_messages') as generate_messages, \
mock.patch('trollflow2.launcher.process') as process, \
mock.patch('trollflow2.launcher.check_results'), \
mock.patch('multiprocessing.get_context'):
generate_messages.side_effect = ['foo', KeyboardInterrupt]
prod_list = {'product_list': {}}
Expand All @@ -400,8 +400,8 @@ def test_run_does_not_call_process_directly(self):
def test_run_relies_on_listener(self):
"""Test running relies on listener."""
from trollflow2.launcher import Runner
with mock.patch('trollflow2.launcher.yaml.load') as yaml_load,\
mock.patch('trollflow2.launcher.open'),\
with mock.patch('trollflow2.launcher.yaml.load') as yaml_load, \
mock.patch('trollflow2.launcher.open'), \
mock.patch('multiprocessing.get_context') as get_context, \
mock.patch('trollflow2.launcher.ListenerContainer') as lc_:
msg = mock.MagicMock()
Expand All @@ -420,7 +420,7 @@ def test_run_relies_on_listener(self):
runner.run()
except KeyboardInterrupt:
pass
listener.output_queue.called_once()
listener.output_queue.get.assert_called_once()
lc_.assert_called_with(addresses=None, nameserver='localhost',
topics=['/topic1', '/topic2'])
# Subscriber topics are removed from config
Expand Down Expand Up @@ -451,9 +451,9 @@ def test_subprocess_is_spawned(self):
def run_on_a_simple_product_list(config):
"""Run a simple (fake) product list."""
from trollflow2.launcher import Runner
with mock.patch('trollflow2.launcher.yaml.load') as yaml_load,\
mock.patch('trollflow2.launcher.open'),\
mock.patch('multiprocessing.get_context') as get_context,\
with mock.patch('trollflow2.launcher.yaml.load') as yaml_load, \
mock.patch('trollflow2.launcher.open'), \
mock.patch('multiprocessing.get_context') as get_context, \
mock.patch('trollflow2.launcher.ListenerContainer') as lc_:

msg = mock.MagicMock()
Expand Down Expand Up @@ -486,8 +486,8 @@ def setUp(self):
def test_run_keyboard_interrupt(self):
"""Test interrupting the run with a ctrl-C."""
from trollflow2.launcher import Runner
with mock.patch('trollflow2.launcher.yaml.load'),\
mock.patch('trollflow2.launcher.open'),\
with mock.patch('trollflow2.launcher.yaml.load'), \
mock.patch('trollflow2.launcher.open'), \
mock.patch('trollflow2.launcher.ListenerContainer') as lc_:
listener = mock.MagicMock()
get = mock.Mock()
Expand Down
3 changes: 2 additions & 1 deletion trollflow2/tests/test_trollflow2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,8 @@ def test_discard_old_data(self):
job = {'product_list': None, 'input_mda': {'start_time': dt.datetime(2020, 3, 18)}}
self.assertIsNone(check_metadata(job))
get_config_value.return_value = {'start_time': -2e6}
self.assertIsNone(check_metadata(job))
with self.assertRaises(AbortProcessing):
check_metadata(job)
mraspaud marked this conversation as resolved.
Show resolved Hide resolved
get_config_value.return_value = {'start_time': -60}
with self.assertRaises(AbortProcessing):
check_metadata(job)
Expand Down
Loading