Beispiel #1
0
    def test_constructor(self):
        container = Container(
            objects=[self.vos_object1, self.vos_object2])
        want = self.test_data.create_default_container()
        assert want == container.dump() # nosec

        container = Container(
            count=300, csum_size=400, csum_gran=500, objects=[
                self.vos_object1, self.vos_object2])
        want = self.test_data.create_default_container(
            count=300, csum_size=400, csum_gran=500)
        assert want == container.dump() # nosec
Beispiel #2
0
    def test_invalid_parameters(self):
        with pytest.raises(TypeError) as err:
            container = Container(count="rubbish")
        assert "count parameter must be of type int" in str(err.value)

        with pytest.raises(TypeError) as err:
            container = Container(csum_size="rubbish")
        assert "csum_size parameter must be of type int" in str(err.value)

        with pytest.raises(TypeError) as err:
            container = Container(csum_gran="rubbish")
        assert "csum_gran parameter must be of type int" in str(err.value)

        with pytest.raises(TypeError) as err:
            container = Container(objects=["rubbish"])
        assert "must be of type" in str(err.value)
Beispiel #3
0
    def setUp(self):
        akey1 = AKey(key="A-key 1",
                     value_type="single_value",
                     values=self.test_data.create_values())
        akey2 = AKey(key="A-key 2",
                     value_type="array",
                     values=self.test_data.create_values())
        self.dkey1 = DKey(key="D-key 1", akeys=[akey1, akey2])
        self.dkey2 = DKey(key="D-key 2", akeys=[akey1, akey2])

        self.vos_object1 = VosObject(count=100, dkeys=[self.dkey1, self.dkey2])
        self.vos_object2 = VosObject(count=200, dkeys=[self.dkey1, self.dkey2])

        self.vos_container1 = Container(
            csum_gran=300, objects=[self.vos_object1, self.vos_object2])
        self.vos_container2 = Container(
            csum_gran=400, objects=[self.vos_object1, self.vos_object2])
Beispiel #4
0
    def test_invalid_parameters(self):
        with pytest.raises(TypeError) as err:
            container = Container(count="rubbish")
        assert "count parameter must be of type int" in str(err.value) # nosec

        with pytest.raises(TypeError) as err:
            container = Container(csum_size="rubbish")
        # pylint: disable=line-too-long
        assert "csum_size parameter must be of type int" in str(err.value) # nosec

        with pytest.raises(TypeError) as err:
            container = Container(csum_gran="rubbish")
        assert "csum_gran parameter must be of type int" in str(err.value) # nosec
        # pylint: enable=line-too-long

        with pytest.raises(TypeError) as err:
            container = Container(objects=["rubbish"])
        assert "must be of type" in str(err.value) # nosec
Beispiel #5
0
    def get_container(self):
        container = Container(objects=self._objects)

        return container
Beispiel #6
0
 def test_add_value(self):
     container = Container()
     container.add_value(self.vos_object1)
     container.add_value(self.vos_object2)
     want = self.test_data.create_default_container()
     assert want == container.dump()