Debian Codegraph @

tests/unit/scripts/test_validate_reinstall_units.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 """Tests for cylc.flow.scripts.validate_reinstall.py
18 """
19
20 import pytest
21
22 from cylc.flow.scripts.validate_reinstall import (
23 check_tvars_and_workflow_stopped)
24
25
26 @pytest.mark.parametrize(
27 'is_running, tvars, tvars_file, expect',
28 [
29 (True, [], None, True),
30 (True, ['FOO="Bar"'], None, False),
31 (True, [], ['bar.txt'], False),
32 (True, ['FOO="Bar"'], ['bar.txt'], False),
33 (False, [], None, True),
34 (False, ['FOO="Bar"'], ['bar.txt'], True),
35 (False, [], ['bar.txt'], True),
36 (False, ['FOO="Bar"'], ['bar.txt'], True),
37 ]
38 )
39 def test_check_tvars_and_workflow_stopped(
40 caplog, is_running, tvars, tvars_file, expect
41 ):
42 """It returns true if workflow is running and tvars or tvars_file is set.
43 """
44 result = check_tvars_and_workflow_stopped(is_running, tvars, tvars_file)
45 assert result == expect
46 if expect is False:
47 warn = 'can only be changed if'
48 assert warn in caplog.records[0].msg