def test_updates(self):
        s1 = Session()
        s2 = Session()

        # create some properties and save
        s1.properties.update(a=1, b="foo")

        # add this session to s2
        s2.add_item(s1)

        self.assertEqual(s1.properties["a"], 1)
        self.assertEqual(s2.items[0].properties["a"], 1)
        self.assertEqual(s1.properties["b"], "foo")
        self.assertEqual(s2.items[0].properties["b"], "foo")

        # update a property on s1
        s1.properties.update(b="bar")

        self.assertEqual(s1.properties.get("b"), "bar")
        self.assertEqual(s2.items[0].properties.get("b"), "bar")
Example #2
0
    def test_updates(self):
        s1 = Session()
        s2 = Session()

        # create some properties and save
        s1.properties.update(a=1, b="foo")

        # add this session to s2
        s2.add_item(s1)

        self.assertEqual(s1.properties["a"], 1)
        self.assertEqual(s2.items[0].properties["a"], 1)
        self.assertEqual(s1.properties["b"], "foo")
        self.assertEqual(s2.items[0].properties["b"], "foo")

        # update a property on s1
        s1.properties.update(b="bar")

        self.assertEqual(s1.properties.get("b"), "bar")
        self.assertEqual(s2.items[0].properties.get("b"), "bar")
    def test_basic(self):
        s = Session()

        # local
        s.properties.update(a=1, b="foo")

        self.assertEqual(len(s.properties), 2)
        self.assertEqual(len(s.properties.local), 2)
        self.assertEqual(len(s.properties.inherited), 0)
        self.assertEqual(s.properties.get("a"), 1)
        self.assertEqual(s.properties.get("b"), "foo")

        # inherited
        s.properties.inherited.update(a=2, b="bar", c=3)

        self.assertEqual(len(s.properties), 3)
        self.assertEqual(len(s.properties.local), 2)
        self.assertEqual(len(s.properties.inherited), 3)
        self.assertEqual(s.properties.get("a"), 1)
        self.assertEqual(s.properties.get("b"), "foo")
        self.assertEqual(s.properties.get("c"), 3)
Example #4
0
    def test_nested(self):
        s1 = Session()
        s2 = Session()

        # create some properties and save
        s1.properties.update(a=1, b="foo")
        s1.save(os.path.join(TEMPDIR, "s1.io"))

        # add this session to s2
        s2.add_item(s1)

        # override one of the properties in s1
        s2.items[0].properties.update(b="bar")

        self.assertEqual(s2.items[0].properties.get("a"), 1)
        self.assertEqual(s2.items[0].properties.get("b"), "bar")

        # save
        s2.save(os.path.join(TEMPDIR, "s2.io"))

        # read it back
        s3 = Session(os.path.join(TEMPDIR, "s2.io"))
        self.assertEqual(s3.items[0].properties.get("a"), 1)
        self.assertEqual(s3.items[0].properties.get("b"), "bar")
    def test_nested(self):
        s1 = Session()
        s2 = Session()

        # create some properties and save
        s1.properties.update(a=1, b="foo")
        s1.save(os.path.join(TEMPDIR, "s1.io"))

        # add this session to s2
        s2.add_item(s1)

        # override one of the properties in s1
        s2.items[0].properties.update(b="bar")

        self.assertEqual(s2.items[0].properties.get("a"), 1)
        self.assertEqual(s2.items[0].properties.get("b"), "bar")

        # save
        s2.save(os.path.join(TEMPDIR, "s2.io"))

        # read it back
        s3 = Session(os.path.join(TEMPDIR, "s2.io"))
        self.assertEqual(s3.items[0].properties.get("a"), 1)
        self.assertEqual(s3.items[0].properties.get("b"), "bar")