3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # pylint: disable=wildcard-import
19 from tools.test_data_yum import bash_yum_info, \
20 conntrack_tools_yum_info, \
22 from tools.yum import YumInfoParser
23 from tools.yum_test_data import bash_expected, pacemaker_expected, \
24 yum_info_installed_header, \
25 yum_info_available_header, \
26 yum_info_available_header2
27 from tools.yum_test_data import conntrack_tools_expected
30 @pytest.mark.parametrize('yum_info, expected_output', [
31 (bash_yum_info, bash_expected),
32 (conntrack_tools_yum_info, conntrack_tools_expected),
33 (pacemaker_yum_info, pacemaker_expected)
35 def test_parse_package(yum_info, expected_output):
36 parsed = YumInfoParser().parse_package(yum_info)
37 expected = expected_output
38 assert parsed == expected
41 def test_parse_installed():
42 fake_out = '\n'.join([yum_info_installed_header,
44 conntrack_tools_yum_info])
45 parsed = YumInfoParser().parse_installed(fake_out)
46 expected = [bash_expected, conntrack_tools_expected]
47 assert parsed == expected
50 @pytest.mark.parametrize('available_header', [
51 yum_info_available_header,
52 yum_info_available_header2
54 def test_parse_available(available_header):
55 fake_out = '\n'.join([available_header,
57 conntrack_tools_yum_info])
58 parsed = YumInfoParser().parse_available(fake_out)
59 expected = [bash_expected, conntrack_tools_expected]
60 assert parsed == expected
63 def test_parse_file():
64 test_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
65 'yum_info_installed.sample')
66 parsed = YumInfoParser().parse_file(test_file)
67 assert len(parsed) == 14