def test_insert_many_append(self):
        m = ObjectStore()
        m.insert_many(-1, range(10))
        self.failUnlessEqual([r[0] for r in m], range(10))

        m = ObjectStore()
        m.insert_many(99, range(10))
        self.failUnlessEqual([r[0] for r in m], range(10))
    def test_filter(self):
        m = ObjectStore()
        f = ObjectModelFilter(child_model=m)
        m.insert_many(0, range(10))

        def filter_func(model, iter_, data):
            if model.get_value(iter_) % 2 == 0:
                return True
            return False

        f.set_visible_func(filter_func)
        f.refilter()
        self.failUnlessEqual(range(0, 10, 2), list(f.itervalues()))
    def test_sort(self):
        m = ObjectStore()
        f = ObjectModelSort(model=m)
        m.insert_many(0, range(10))

        def sort_func(model, iter_a, iter_b, data):
            a = model.get_value(iter_a, 0)
            b = model.get_value(iter_b, 0)
            return -cmp(a, b)

        f.set_default_sort_func(sort_func)

        self.failUnlessEqual(sorted(range(10), reverse=True),
                             list(f.itervalues()))
    def test_signal_count(self):
        m = ObjectStore()

        def handler(model, path, iter_, result):
            result[0] += 1

        inserted = [0]
        m.connect("row-inserted", handler, inserted)
        changed = [0]
        m.connect("row-changed", handler, changed)

        m.append([1])
        m.prepend([8])
        m.insert(0, [1])
        m.insert_before(None, [1])
        m.insert_after(None, [1])
        m.insert_many(0, [1, 2, 3])
        m.append_many([1, 2, 3])
        list(m.iter_append_many([1, 2, 3]))
        list(m.iter_append_many(xrange(3)))

        self.assertEqual(changed[0], 0)
        self.assertEqual(inserted[0], len(m))
 def test_iter_values(self):
     m = ObjectStore()
     f = ObjectModelSort(model=m)
     m.insert_many(0, range(10))
     self.failUnlessEqual(range(10), list(f.itervalues()))
 def test_iterrows(self):
     m = ObjectStore()
     m.insert_many(0, range(10))
     for iter_, value in m.iterrows():
         self.failUnlessEqual(m.get_value(iter_), value)
 def test_itervalues(self):
     m = ObjectStore()
     m.insert_many(0, range(10))
     self.failUnlessEqual(range(10), list(m.itervalues()))
 def test_insert_many(self):
     m = ObjectStore()
     m.append(row=[42])
     m.append(row=[24])
     m.insert_many(1, range(10))
     self.failUnlessEqual([r[0] for r in m], [42] + range(10) + [24])
Esempio n. 9
0
 def test_insert_many(self):
     m = ObjectStore()
     m.append(row=[42])
     m.append(row=[24])
     m.insert_many(1, range(10))
     self.failUnlessEqual([r[0] for r in m], [42] + list(range(10)) + [24])
Esempio n. 10
0
 def test_iter_values(self):
     m = ObjectStore()
     f = ObjectModelSort(model=m)
     m.insert_many(0, range(10))
     self.failUnlessEqual(list(range(10)), list(f.itervalues()))
Esempio n. 11
0
 def test_iterrows(self):
     m = ObjectStore()
     m.insert_many(0, range(10))
     for iter_, value in m.iterrows():
         self.failUnlessEqual(m.get_value(iter_), value)
Esempio n. 12
0
 def test_itervalues(self):
     m = ObjectStore()
     m.insert_many(0, range(10))
     self.failUnlessEqual(list(range(10)), list(m.itervalues()))