예제 #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
예제 #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())
예제 #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()
예제 #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)
예제 #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)
예제 #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