2019-04-10 10:23:56 -07:00
|
|
|
import json
|
2019-03-28 12:09:09 -07:00
|
|
|
import unittest
|
2019-04-10 18:03:58 -07:00
|
|
|
from io import StringIO
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest.mock import PropertyMock, patch
|
2019-03-28 12:09:09 -07:00
|
|
|
|
|
|
|
from hypothesis import given
|
2019-04-10 18:03:58 -07:00
|
|
|
from hypothesis.strategies import characters, one_of, lists, text
|
|
|
|
|
2019-04-09 17:45:38 -07:00
|
|
|
from rbackup.struct.hierarchy import Hierarchy
|
2019-03-13 03:13:32 -07:00
|
|
|
|
2019-03-13 20:38:22 -07:00
|
|
|
# ========== Constants ==========
|
2019-04-10 18:00:47 -07:00
|
|
|
TESTING_PACKAGE = "rbackup.struct"
|
|
|
|
TESTING_MODULE = f"{TESTING_PACKAGE}.hierarchy"
|
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)
|