Beispiel #1
0
    def test_parameters(self):
        json = """
        { "types": [
            { "type": "A",
              "parameters": {
                "s": "string",
                "d": "datetime",
                "i": "integer"
              }
            }
          ],
          "objects": [
            { "type": "A",
              "parameters": {
                "s": "string",
                "d": "2012-02-10T20:00:00",
                "i": 12
              } },
            { "type": "A" },
            { "type": "A" }
          ],
          "relations": []
          }"""

        jio = JsonIO(self.mapper, add_new_types=True)
        objs = jio.read_string(json)
        self.assertEqual(len(objs), 3)
        self.assertEqual(objs[0].params["s"], "string")
        self.assertEqual(objs[0].params["d"], datetime.datetime(2012, 2, 10, 20, 0, 0))
        self.assertEqual(objs[0].params["i"], 12)
Beispiel #2
0
    def test_simple_import(self):
        json = """
        { "types": [{"type": "A"}, {"type": "B"}],
          "objects": [{"type": "A"}, {"type": "A"}, {"type": "A"}, {"type": "B"}],
          "relations": []
          }"""

        jio = JsonIO(self.mapper, add_new_types=True)
        objs = jio.read_string(json)
        self.assertEqual(len(objs), 4)
Beispiel #3
0
    def test_null_import(self):
        json = """
        { "types": [],
          "objects": [],
          "relations": []
          }"""

        jio = JsonIO(self.mapper)
        objs = jio.read_string(json)
        self.assertEqual(len(objs), 0)