mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
3033fd96b0
* Move ansible.compat.tests to test/units/compat/. * Fix unit test references to ansible.compat.tests. * Move builtins compat to separate file. * Fix classification of test/units/compat/ dir.
25 lines
814 B
Python
25 lines
814 B
Python
import os
|
|
import tempfile
|
|
|
|
from units.compat import unittest
|
|
from ansible.module_utils._text import to_bytes
|
|
|
|
from ansible.modules.system.mount import get_linux_mounts
|
|
|
|
|
|
class LinuxMountsTestCase(unittest.TestCase):
|
|
|
|
def _create_file(self, content):
|
|
tmp_file = tempfile.NamedTemporaryFile(prefix='ansible-test-', delete=False)
|
|
tmp_file.write(to_bytes(content))
|
|
tmp_file.close()
|
|
self.addCleanup(os.unlink, tmp_file.name)
|
|
return tmp_file.name
|
|
|
|
def test_code_comment(self):
|
|
path = self._create_file(
|
|
'140 136 253:2 /rootfs / rw - ext4 /dev/sdb2 rw\n'
|
|
'141 140 253:2 /rootfs/tmp/aaa /tmp/bbb rw - ext4 /dev/sdb2 rw\n'
|
|
)
|
|
mounts = get_linux_mounts(None, path)
|
|
self.assertEqual(mounts['/tmp/bbb']['src'], '/tmp/aaa')
|