mirror of https://github.com/nucypher/nucypher.git
Add test for client._split_path method
parent
be664574ea
commit
2d6c4327bb
|
@ -51,12 +51,12 @@ class Client(object):
|
|||
priv = kmac.KMAC_256().digest(self._priv_key, path.encode())
|
||||
return self._pre.priv2pub(priv) if is_pub else priv
|
||||
|
||||
def _split_path(path):
|
||||
def _split_path(self, path):
|
||||
"""
|
||||
Splits the file path provided and provides subpaths to each directory.
|
||||
|
||||
:param bytes path: Path to file
|
||||
|
||||
|
||||
:return: Subpath(s) from path
|
||||
:rtype: list of bytes
|
||||
"""
|
||||
|
|
|
@ -24,6 +24,16 @@ class TestClient(unittest.TestCase):
|
|||
|
||||
self.assertNotEqual(pub_path_key, priv_path_key)
|
||||
|
||||
def test_split_path(self):
|
||||
path = b'/foo/bar/test.jpg'
|
||||
subdirs = self.client._split_path(path)
|
||||
|
||||
self.assertEqual(4, len(subdirs))
|
||||
self.assertEqual(subdirs[0], b'')
|
||||
self.assertEqual(subdirs[1], b'/foo')
|
||||
self.assertEqual(subdirs[2], b'/foo/bar')
|
||||
self.assertEqual(subdirs[3], b'/foo/bar/test.jpg')
|
||||
|
||||
def test_encrypt_key_with_path_tuple(self):
|
||||
key = random(32)
|
||||
path = ('/', '/foo', '/foo/bar')
|
||||
|
|
Loading…
Reference in New Issue