def test_constructor(self): containers = Containers( num_shards=200, containers=[self.vos_container1, self.vos_container2]) raw_container1 = self.test_data.create_default_container(csum_gran=300) raw_container2 = self.test_data.create_default_container(csum_gran=400) want = { "num_shards": 200, "containers": [raw_container1, raw_container2] } assert want == containers.dump()
def _get_yaml_from_dfs(self, fse, use_average=False): dfs_sb = get_dfs_sb_obj() if use_average: dfs = fse.get_dfs_average() else: dfs = fse.get_dfs() container = dfs.get_container() container.add_value(dfs_sb) containers = Containers() containers.add_value(container) containers.set_num_shards(self._args.num_shards) return containers.dump()
def test_invalid_parameters(self): with pytest.raises(VosValueError) as err: containers = Containers() containers.dump() assert "list of containers must not be empty" in str(err.value) with pytest.raises(TypeError) as err: container = Containers(num_shards="rubbish") assert "num_shards parameter must be of type int" in str(err.value) with pytest.raises(TypeError) as err: container = Containers(containers=["rubbish"]) assert "must be of type" in str(err.value)
def test_invalid_parameters(self): with pytest.raises(VosValueError) as err: containers = Containers() containers.dump() assert "list of containers must not be empty" in str(err.value) # nosec with pytest.raises(TypeError) as err: container = Containers(num_shards="rubbish") # pylint: disable=line-too-long assert "num_shards parameter must be of type int" in str(err.value) # nosec # pylint: enable=line-too-long with pytest.raises(TypeError) as err: container = Containers(containers=["rubbish"]) assert "must be of type" in str(err.value) # nosec
def test_add_value(self): with pytest.raises(TypeError) as err: containers = Containers() containers.add_value("rubbish") assert "must be of type" in str(err.value) with pytest.raises(TypeError) as err: containers = Containers() containers.set_num_shards("rubbish") assert "num_shards parameter must be of type int" in str(err.value) containers = Containers() containers.add_value(self.vos_container1) containers.add_value(self.vos_container2) containers.set_num_shards(500) raw_container1 = self.test_data.create_default_container(csum_gran=300) raw_container2 = self.test_data.create_default_container(csum_gran=400) want = { "num_shards": 500, "containers": [raw_container1, raw_container2] } assert want == containers.dump()