From 406930e3999c2e68b4e9d6572ba17ab74b6c7352 Mon Sep 17 00:00:00 2001 From: Maciej Kisielewski Date: Tue, 20 Feb 2024 17:25:21 +0100 Subject: [PATCH] add tiny bit of tests to the storage tests --- providers/base/tests/test_storage_test.py | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 providers/base/tests/test_storage_test.py diff --git a/providers/base/tests/test_storage_test.py b/providers/base/tests/test_storage_test.py new file mode 100644 index 000000000..8c80fe5a4 --- /dev/null +++ b/providers/base/tests/test_storage_test.py @@ -0,0 +1,30 @@ +import unittest +from unittest.mock import patch, MagicMock + + +from storage_test import mountpoint + +class TestMountpoint(unittest.TestCase): + @patch("psutil.disk_partitions") + def test_mountpoint_nominal(self, mock_disk_partitions): + + sdiskpart = MagicMock() + sdiskpart.device = '/dev/sda1' + sdiskpart.mountpoint = '/' + mock_disk_partitions.return_value = [sdiskpart] + self.assertEqual(mountpoint("/dev/sda1"), "/") + + @patch("psutil.disk_partitions") + def test_mountpoint_nominal_multiple(self, mock_disk_partitions): + + mock_disk_partitions.return_value = [ + MagicMock(device='/dev/sda1', mountpoint='/'), + MagicMock(device='/dev/sda2', mountpoint='/boot') + ] + self.assertEqual(mountpoint("/dev/sda2"), "/boot") + + + @patch("psutil.disk_partitions") + def test_mountpoint_empty(self, mock_disk_partitions): + mock_disk_partitions.return_value = [] + self.assertEqual(mountpoint('/dev/sda1'), None)