Debian Codegraph @

tests/u/test_dbstatecheck.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 from cylc.flow.dbstatecheck import check_polling_config
18 from cylc.flow.exceptions import InputError
19
20 import pytest
21
22
23 def test_check_polling_config():
24 """It should reject invalid or unreliable polling configurations.
25
26 See https://github.com/cylc/cylc-flow/issues/6157
27 """
28 # invalid polling use cases
29 with pytest.raises(InputError, match='No such task state'):
30 check_polling_config('elephant', False, False)
31
32 with pytest.raises(InputError, match='Cannot poll for'):
33 check_polling_config('waiting', False, False)
34
35 with pytest.raises(InputError, match='is not reliable'):
36 check_polling_config('running', False, False)
37
38 # valid polling use cases
39 check_polling_config('started', True, False)
40 check_polling_config('started', False, True)
41
42 # valid query use cases
43 check_polling_config(None, False, True)
44 check_polling_config(None, False, False)