Test reconstruct() with no EC policies

We have a test for get_local_devices, but let's make some broader
assertions as well.

Related-Bug: #1707595
Change-Id: Ifa696207ffdb3b39650dfeaa3e7c6cfda94050db
This commit is contained in:
Tim Burke 2017-07-31 17:24:40 +00:00 committed by Alistair Coles
parent 45cc1d02d0
commit 8d05325f03

View File

@ -3864,12 +3864,34 @@ class TestObjectReconstructor(BaseTestObjectReconstructor):
def test_get_local_devices_with_no_ec_policy_env(self): def test_get_local_devices_with_no_ec_policy_env(self):
# even no ec_policy found on the server, it runs just like as # even no ec_policy found on the server, it runs just like as
# no ec device found # no ec device found
self.policy = POLICIES.default
self._configure_reconstructor() self._configure_reconstructor()
self.assertEqual([], self.reconstructor.policies) self.assertEqual([], self.reconstructor.policies)
local_devs = self.reconstructor.get_local_devices() local_devs = self.reconstructor.get_local_devices()
self.assertEqual(set(), local_devs) self.assertEqual(set(), local_devs)
@patch_policies(legacy_only=True)
def test_reconstruct_with_no_ec_policy_env(self):
self._configure_reconstructor()
self.assertEqual([], self.reconstructor.policies)
collect_parts_results = []
_orig_collect_parts = self.reconstructor.collect_parts
def capture_collect_parts(**kwargs):
part_infos = _orig_collect_parts(**kwargs)
collect_parts_results.append(part_infos)
return part_infos
with mock.patch.object(self.reconstructor, 'collect_parts',
capture_collect_parts):
self.reconstructor.reconstruct()
# There is one call, and it returns an empty list
self.assertEqual([[]], collect_parts_results)
log_lines = self.logger.all_log_lines()
self.assertEqual(log_lines, {'info': [mock.ANY]})
line = log_lines['info'][0]
self.assertTrue(line.startswith('Nothing reconstructed '), line)
class TestReconstructFragmentArchive(BaseTestObjectReconstructor): class TestReconstructFragmentArchive(BaseTestObjectReconstructor):
obj_path = '/a/c/o' # subclass overrides this obj_path = '/a/c/o' # subclass overrides this