Split tests into specifically named test cases

This commit is contained in:
Eric Torres 2019-05-01 11:28:47 -07:00
parent f06acc20a5
commit f33cf3c8a9

View File

@ -8,9 +8,6 @@ import unittest
from pathlib import Path
from unittest.mock import DEFAULT, patch
from hypothesis import given
from hypothesis.strategies import from_regex
from rbackup.struct.hierarchy import Hierarchy
# ========== Constants ==========
@ -20,6 +17,8 @@ TESTING_MODULE = f"{TESTING_PACKAGE}.hierarchy"
# ========== Tests ==========
class TestHierarchyPaths(unittest.TestCase):
"""Check given path properties of a Hierarchy object."""
def setUp(self):
self.patched_path = patch.multiple(
Path, exists=DEFAULT, mkdir=DEFAULT, symlink_to=DEFAULT, touch=DEFAULT
@ -30,16 +29,29 @@ class TestHierarchyPaths(unittest.TestCase):
def test_retrieves_correct_metadata_filename(self):
self.assertEqual(Hierarchy("/tmp/backup").metadata_path.name, ".metadata")
def test_raises_notimplemented_error(self):
h = Hierarchy("/tmp/backup")
with self.assertRaises(NotImplementedError):
h._gen_metadata()
def tearDown(self):
patch.stopall()
class TestHierarchyMetadata(unittest.TestCase):
"""Test intrusive metadata methods of a Hierarchy object."""
def setUp(self):
self.patched_path = patch.multiple(
Path, exists=DEFAULT, mkdir=DEFAULT, symlink_to=DEFAULT, touch=DEFAULT
)
self.mocked_path = self.patched_path.start()
def test_gen_metadata_raises_notimplemented_error(self):
with self.assertRaises(NotImplementedError):
Hierarchy("/tmp/backup")._gen_metadata()
def tearDown(self):
patch.stopall()
class TestHierarchyMetadataIO(unittest.TestCase):
"""Only meant to check that data written is the same data that is read."""
def test_write_metadata(self):