Exemplo n.º 1
0
 def test_value_interleaved_rows_nested_maps_with_same_indexes(self):
     model = MapModel(Map(["a"], [0.0]))
     model.insertRows(1, 3)
     self.assertEqual(model.rowCount(), 5)
     model.append_column()
     self.assertEqual(model.columnCount(), 4)
     model.setData(model.index(0, 0), "key1")
     model.setData(model.index(0, 1), "kkey1")
     model.setData(model.index(0, 2), "value11")
     model.setData(model.index(1, 0), "key2")
     model.setData(model.index(1, 1), "kkey1")
     model.setData(model.index(1, 2), "value21")
     model.setData(model.index(2, 0), "key1")
     model.setData(model.index(2, 1), "kkey2")
     model.setData(model.index(2, 2), "value12")
     model.setData(model.index(3, 0), "key2")
     model.setData(model.index(3, 1), "kkey2")
     model.setData(model.index(3, 2), "value22")
     map_ = model.value()
     self.assertEqual(map_.indexes, ["key1", "key2"])
     self.assertIsInstance(map_.values[0], Map)
     self.assertEqual(map_.values[0].indexes, ["kkey1", "kkey2"])
     self.assertEqual(map_.values[0].values, ["value11", "value12"])
     self.assertIsInstance(map_.values[1], Map)
     self.assertEqual(map_.values[1].indexes, ["kkey1", "kkey2"])
     self.assertEqual(map_.values[1].values, ["value21", "value22"])
Exemplo n.º 2
0
 def test_append_column(self):
     nested_map = Map(["a", "b"], [1.1, 2.2])
     map_value = Map(["A", "B"], [-1.1, nested_map])
     model = MapModel(map_value)
     model.append_column()
     self.assertEqual(model.columnCount(), 5)
     expected_table = [
         ["A", -1.1, None, None, ""],
         ["B", "a", 1.1, None, ""],
         ["B", "b", 2.2, None, ""],
         ["", "", "", "", ""],
     ]
     for y, row in enumerate(expected_table):
         for x, expected in enumerate(row):
             index = model.index(y, x)
             self.assertEqual(index.data(), expected)
Exemplo n.º 3
0
 def test_value_interleaved_rows(self):
     model = MapModel(Map(["a"], [0.0]))
     model.insertRows(1, 2)
     self.assertEqual(model.rowCount(), 4)
     model.append_column()
     self.assertEqual(model.columnCount(), 4)
     model.setData(model.index(0, 0), "key1")
     model.setData(model.index(0, 1), "a")
     model.setData(model.index(0, 2), -2.0)
     model.setData(model.index(1, 0), "key2")
     model.setData(model.index(1, 1), 23.0)
     model.setData(model.index(2, 0), "key1")
     model.setData(model.index(2, 1), "b")
     model.setData(model.index(2, 2), -3.0)
     map_ = model.value()
     self.assertEqual(map_.indexes, ["key1", "key2"])
     self.assertIsInstance(map_.values[0], Map)
     self.assertEqual(map_.values[0].indexes, ["a", "b"])
     self.assertEqual(map_.values[0].values, [-2.0, -3.0])
     self.assertEqual(map_.values[1], 23.0)
Exemplo n.º 4
0
 def test_trim_columns(self):
     map_value = Map(["a"], [1.1])
     model = MapModel(map_value)
     model.append_column()
     model.trim_columns()
     self.assertEqual(model.columnCount(), 3)