Debian Codegraph @

test/units/module_utils/facts/test_utils.py

raw
1 # This file is part of Ansible
2 #
3 # Ansible is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # Ansible is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
15
16 from __future__ import annotations
17
18 import unittest
19 from unittest.mock import patch
20
21 from ansible.module_utils.facts import utils
22
23
24 class TestGetMountSize(unittest.TestCase):
25 def test(self):
26 mount_info = utils.get_mount_size('/dev/null/not/a/real/mountpoint')
27 self.assertIsInstance(mount_info, dict)
28
29 def test_proc(self):
30 mount_info = utils.get_mount_size('/proc')
31 self.assertIsInstance(mount_info, dict)
32
33 @patch('ansible.module_utils.facts.utils.os.statvfs', side_effect=OSError('intentionally induced os error'))
34 def test_oserror_on_statvfs(self, mock_statvfs):
35 mount_info = utils.get_mount_size('/dev/null/does/not/matter')
36 self.assertIsInstance(mount_info, dict)
37 self.assertDictEqual(mount_info, {})