Add some unit tests for hierarchy module

This commit is contained in:
Eric Torres 2019-03-13 03:13:32 -07:00
parent a6a670f77f
commit 5b27f5c3d6

47
tests/test_hierarchy.py Normal file
View File

@ -0,0 +1,47 @@
import rbackup.hierarchy as hierarchy
import unittest
from unittest.mock import MagicMock, patch
class TestHierarchy(unittest.TestCase):
def setUp(self):
self.patched_os_path = patch('rbackup.hierarchy.os.path')
self.mocked_os_path = self.patched_os_path.start()
self.mocked_os_path.isdir.return_value = True
self.hier = hierarchy.Hierarchy('/mnt')
@patch("rbackup.hierarchy.os.path.isdir")
def test_non_dir(self, patched_false_isdir):
patched_false_isdir.return_value = False
with self.assertRaises(ValueError):
h = hierarchy.Hierarchy('NotADir')
def test_base_path(self):
self.assertEqual(self.hier.base_dir, "/mnt")
def test_prev_snapshot(self):
raise NotImplementedError
def test_prev_snapshot_link(self):
raise NotImplementedError
def test_curr_snapshot(self):
raise NotImplementedError
def test_boot_dir(self):
raise NotImplementedError
def test_etc_dir(self):
raise NotImplementedError
def test_home_dir(self):
raise NotImplementedError
def test_root_home_dir(self):
raise NotImplementedError
def tearDown(self):
self.patched_os_path.stop()