-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tiny bit of tests to the storage tests (New) (#1004)
* add tiny bit of tests to the storage tests * add psutil to the base prov. tox.ini * add psutil also for py36
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters