summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTushar Gohad <tushar.gohad@intel.com>2015-07-16 11:18:53 -0700
committerTushar Gohad <tushar.gohad@intel.com>2015-07-19 18:49:34 -0700
commit04700a4fcf9efc3f3e945e8a91d1ebad9ccf477d (patch)
tree7fb2aa11ef26d00206aeb11f3f640bbb1345f809 /test
parent43868eaa34de93e03d849f521c21c84f3aa17b23 (diff)
downloadpyeclib-04700a4fcf9efc3f3e945e8a91d1ebad9ccf477d.tar.gz
Expose liberasurecode error codes in PyECLib
... also move exception handing down to the C backend layer, so it is easier to add new error codes. Addresses #61.
Diffstat (limited to 'test')
-rw-r--r--test/test_pyeclib_api.py48
1 files changed, 23 insertions, 25 deletions
diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py
index 71552c1..d26bfbe 100644
--- a/test/test_pyeclib_api.py
+++ b/test/test_pyeclib_api.py
@@ -27,11 +27,10 @@ import sys
import tempfile
import unittest
from pyeclib.ec_iface import ECDriverError
+from pyeclib.ec_iface import ECInsufficientFragments
-from pyeclib.ec_iface import ECDriver, VALID_EC_TYPES, ECDriverError, \
- PyECLib_EC_Types
+from pyeclib.ec_iface import ECDriver, PyECLib_EC_Types
from test_pyeclib_c import _available_backends
-import pyeclib_c
if sys.version < '3':
def b2i(b):
@@ -519,28 +518,27 @@ class TestPyECLibDriver(unittest.TestCase):
self.assertTrue(got_exception)
def test_liberasurecode_error(self):
- pyeclib_driver = self.get_available_backend(k=10, m=5, ec_type="flat_xor_hd_3")
- file_size = self.file_sizes[0]
- tmp_file = self.files[file_size]
- tmp_file.seek(0)
- whole_file_str = tmp_file.read()
- whole_file_bytes = whole_file_str.encode('utf-8')
- hit_exception = False
-
- fragments = pyeclib_driver.encode(whole_file_bytes)
-
- #
- # Test reconstructor with insufficient fragments
- #
- try:
- pyeclib_driver.reconstruct([fragments[0]], [1,2,3,4,5,6])
- except ECDriverError as e:
- hit_exception = True
- print(e.error_str.__str__())
- self.assertTrue(e.error_str.__str__().find("Insufficient number of fragments") > -1)
-
- self.assertTrue(hit_exception)
-
+ pyeclib_driver = self.get_available_backend(k=10, m=5, ec_type="flat_xor_hd_3")
+ file_size = self.file_sizes[0]
+ tmp_file = self.files[file_size]
+ tmp_file.seek(0)
+ whole_file_str = tmp_file.read()
+ whole_file_bytes = whole_file_str.encode('utf-8')
+ hit_exception = False
+
+ fragments = pyeclib_driver.encode(whole_file_bytes)
+
+ #
+ # Test reconstructor with insufficient fragments
+ #
+ try:
+ pyeclib_driver.reconstruct([fragments[0]], [1, 2, 3, 4, 5, 6])
+ except ECInsufficientFragments as e:
+ hit_exception = True
+ self.assertTrue(e.error_str.__str__().find("Insufficient number of fragments") > -1)
+
+ self.assertTrue(hit_exception)
+
def test_min_parity_fragments_needed(self):
pyeclib_drivers = []
pyeclib_drivers.append(ECDriver(k=12, m=2, ec_type="jerasure_rs_vand"))