2019-03-16 07:46:03 -07:00
|
|
|
import doctest
|
2019-03-28 12:09:09 -07:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from hypothesis import given
|
|
|
|
from hypothesis.strategies import booleans, characters, iterables, one_of, none, text
|
|
|
|
from pathlib import Path
|
|
|
|
from rbackup.hierarchy.hierarchy import Hierarchy
|
2019-03-13 03:13:32 -07:00
|
|
|
|
2019-03-13 20:38:22 -07:00
|
|
|
# ========== Constants ==========
|
2019-03-16 07:46:03 -07:00
|
|
|
TESTING_MODULE = "rbackup.hierarchy.hierarchy"
|
2019-03-13 20:38:22 -07:00
|
|
|
|
|
|
|
|
2019-03-16 07:46:03 -07:00
|
|
|
# ========== Functions ==========
|
|
|
|
def load_tests(loader, tests, ignore):
|
|
|
|
tests.addTests(doctest.DocTestSuite(TESTING_MODULE))
|
|
|
|
return tests
|
2019-03-28 12:09:09 -07:00
|
|
|
|
|
|
|
|
|
|
|
# ========== Tests ==========
|
|
|
|
class TestHierarchyPaths(unittest.TestCase):
|
|
|
|
@given(one_of(text(), characters()))
|
|
|
|
def test_returns_correct_path(self, p):
|
|
|
|
self.assertEqual(Path(p), Hierarchy(p).path)
|
|
|
|
|
|
|
|
@given(one_of(iterables(elements=none()), booleans()))
|
|
|
|
def test_raises_value_error(self, p):
|
|
|
|
with self.assertRaises(TypeError):
|
|
|
|
Hierarchy(p)
|