Ejemplo n.º 1
0
 def test_validate_from_good_table(self):
     tm = self.tm
     t = Table(tm)
     t.c1 = ["me", "me3"]
     t_serialized = t.to_dict()
     t = tm.validate(t)
     assert t.to_dict() == t_serialized
Ejemplo n.º 2
0
 def test_dict_roundtrip(self):
     t = Table(self.meta)
     d = t.to_dict()
     d2 = d.copy()
     d2.pop("typeid")
     t2 = Table(self.meta, d2)
     self.assertEqual(d, t2.to_dict())
Ejemplo n.º 3
0
 def test_dict_roundtrip(self):
     t = Table(self.meta)
     d = t.to_dict()
     d2 = d.copy()
     d2.pop("typeid")
     t2 = Table(self.meta, d2)
     assert d == t2.to_dict()
Ejemplo n.º 4
0
 def test_validate_from_good_table(self):
     tm = self.tm
     t = Table(tm)
     t.c1 = ["me", "me3"]
     t_serialized = t.to_dict()
     t = tm.validate(t)
     self.assertEqual(t.to_dict(), t_serialized)
Ejemplo n.º 5
0
    def test_to_dict(self):
        t = Table(self.meta)
        t.e1 = ["value"]
        t.e2 = [1, 2]
        t.e3 = [0]

        expected = OrderedDict()
        expected["typeid"] = "malcolm:core/Table:1.0"
        expected["e1"] = ["value"]
        expected["e2"] = [1, 2]
        expected["e3"] = [0]
        actual = t.to_dict()
        # numpy compare gets in the way...
        for k, v in actual.items():
            if k != "typeid":
                actual[k] = list(v)
        self.assertEquals(expected, actual)
Ejemplo n.º 6
0
    def test_to_dict(self):
        t = Table(self.meta)
        t.e1 = ["value"]
        t.e2 = [1, 2]
        t.e3 = [0]

        expected = OrderedDict()
        expected["typeid"] = "malcolm:core/Table:1.0"
        expected["e1"] = ["value"]
        expected["e2"] = [1, 2]
        expected["e3"] = [0]
        actual = t.to_dict()
        # numpy compare gets in the way...
        for k, v in actual.items():
            if k != "typeid":
                actual[k] = list(v)
        assert expected == actual