From f33cf3c8a9d5a5d0d775a71848e5dc4e448dc6f7 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Wed, 1 May 2019 11:28:47 -0700 Subject: [PATCH] Split tests into specifically named test cases --- tests/test_hierarchy.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/test_hierarchy.py b/tests/test_hierarchy.py index d13e09b..dafbf46 100644 --- a/tests/test_hierarchy.py +++ b/tests/test_hierarchy.py @@ -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):