Skip to content

Commit

Permalink
add tiny bit of tests to the storage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kissiel committed Mar 18, 2024
1 parent d8063c2 commit 406930e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions providers/base/tests/test_storage_test.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 406930e

Please sign in to comment.