Esempio n. 1
0
    def test_identity_filter_rerange (self):

        full_model = Model ()
        ranged_model = RangeFilteredLogModel (full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset ()
        filtered_model = FilteredLogModel (ranged_model)
        row_list = self.__row_list

        self.assertEquals (row_list (full_model), range (20))
        self.assertEquals (row_list (ranged_model), range (20))
        self.assertEquals (row_list (filtered_model), range (20))

        filtered_model.add_filter (IdentityFilter (),
                                   Common.Data.DefaultDispatcher ())
        ranged_model.set_range (5, 16)
        filtered_model.super_model_changed_range ()

        self.assertEquals (row_list (ranged_model), range (5, 16))
        self.assertEquals (row_list (filtered_model), range (5, 16))

        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (11)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (11)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (5, 16)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (11)],
                           range (5, 16))
Esempio n. 2
0
    def test_identity_filter_rerange(self):

        full_model = Model()
        ranged_model = RangeFilteredLogModel(full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset()
        filtered_model = FilteredLogModel(ranged_model)
        row_list = self.__row_list

        self.assertEquals(row_list(full_model), range(20))
        self.assertEquals(row_list(ranged_model), range(20))
        self.assertEquals(row_list(filtered_model), range(20))

        filtered_model.add_filter(IdentityFilter(),
                                  Common.Data.DefaultDispatcher())
        ranged_model.set_range(5, 16)
        filtered_model.super_model_changed_range()

        self.assertEquals(row_list(ranged_model), range(5, 16))
        self.assertEquals(row_list(filtered_model), range(5, 16))

        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(11)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(11)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(5, 16)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(11)],
            range(5, 16))
Esempio n. 3
0
    def test_random_filtered_range_refilter(self):

        full_model = Model()
        ranged_model = RangeFilteredLogModel(full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset()
        filtered_model = FilteredLogModel(ranged_model)
        row_list = self.__row_list

        self.assertEquals(row_list(full_model), range(20))
        self.assertEquals(row_list(ranged_model), range(20))
        self.assertEquals(row_list(filtered_model), range(20))

        filtered_model.add_filter(RandomFilter(538295943),
                                  Common.Data.DefaultDispatcher())
        random_rows = row_list(filtered_model)

        self.__dump_model(filtered_model)
        ranged_model.set_range(10, 20)
        self.__dump_model(ranged_model, "ranged_model (10, 20)")
        self.assertEquals(row_list(ranged_model), range(10, 20))
        filtered_model.super_model_changed_range()
        self.__dump_model(filtered_model)
        self.assertEquals(row_list(filtered_model),
                          [x for x in range(10, 20) if x in random_rows])

        ranged_model.set_range(0, 20)
        self.assertEquals(row_list(ranged_model), range(0, 20))

        ranged_model = RangeFilteredLogModel(full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset()
        filtered_model = FilteredLogModel(ranged_model)
        filtered_model.add_filter(RandomFilter(538295943),
                                  Common.Data.DefaultDispatcher())
        self.__dump_model(filtered_model, "filtered model")
        self.assertEquals(row_list(filtered_model), random_rows)

        ranged_model.set_range(0, 10)
        self.__dump_model(ranged_model, "ranged model (0, 10)")
        filtered_model.super_model_changed_range()
        self.assertEquals(row_list(ranged_model), range(0, 10))
        self.__dump_model(filtered_model)
        self.assertEquals(row_list(filtered_model),
                          [x for x in range(0, 10) if x in random_rows])
Esempio n. 4
0
    def test_random_filtered_range_refilter (self):

        full_model = Model ()
        ranged_model = RangeFilteredLogModel (full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset ()
        filtered_model = FilteredLogModel (ranged_model)
        row_list = self.__row_list

        self.assertEquals (row_list (full_model), range (20))
        self.assertEquals (row_list (ranged_model), range (20))
        self.assertEquals (row_list (filtered_model), range (20))

        filtered_model.add_filter (RandomFilter (538295943),
                                   Common.Data.DefaultDispatcher ())
        random_rows = row_list (filtered_model)

        self.__dump_model (filtered_model)
        ranged_model.set_range (10, 20)
        self.__dump_model (ranged_model, "ranged_model (10, 20)")
        self.assertEquals (row_list (ranged_model), range (10, 20))
        filtered_model.super_model_changed_range ()
        self.__dump_model (filtered_model)
        self.assertEquals (row_list (filtered_model), [x for x in range (10, 20) if x in random_rows])

        ranged_model.set_range (0, 20)
        self.assertEquals (row_list (ranged_model), range (0, 20))

        ranged_model = RangeFilteredLogModel (full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset ()
        filtered_model = FilteredLogModel (ranged_model)
        filtered_model.add_filter (RandomFilter (538295943),
                                   Common.Data.DefaultDispatcher ())
        self.__dump_model (filtered_model, "filtered model")
        self.assertEquals (row_list (filtered_model), random_rows)

        ranged_model.set_range (0, 10)
        self.__dump_model (ranged_model, "ranged model (0, 10)")
        filtered_model.super_model_changed_range ()
        self.assertEquals (row_list (ranged_model), range (0, 10))
        self.__dump_model (filtered_model)
        self.assertEquals (row_list (filtered_model), [x for x in range (0, 10) if x in random_rows])
Esempio n. 5
0
    def test_filtered_range_refilter (self):

        full_model = Model ()
        ranged_model = RangeFilteredLogModel (full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset ()
        filtered_model = FilteredLogModel (ranged_model)

        row_list = self.__row_list
        rows = row_list (full_model)
        rows_ranged = row_list (ranged_model)
        rows_filtered = row_list (filtered_model)

        self.__dump_model (full_model, "full model")
        ## self.__dump_model (ranged_model, "ranged model")
        ## self.__dump_model (filtered_model, "filtered model")

        self.assertEquals (rows, rows_ranged)
        self.assertEquals (rows, rows_filtered)

        self.assertEquals ([ranged_model.line_index_from_super (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([ranged_model.line_index_to_super (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([ranged_model.line_index_from_top (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([ranged_model.line_index_to_top (i)
                            for i in range (20)],
                           range (20))

        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (20)],
                           range (20))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (20)],
                           range (20))

        ranged_model.set_range (5, 16)
        self.__dump_model (ranged_model, "ranged model (5, 16)")
        filtered_model.super_model_changed_range ()

        rows_ranged = row_list (ranged_model)
        self.assertEquals (rows_ranged, range (5, 16))

        self.__dump_model (filtered_model, "filtered model (nofilter, 5, 15)")

        rows_filtered = row_list (filtered_model)
        self.assertEquals (rows_ranged, rows_filtered)

        self.assertEquals ([ranged_model.line_index_from_super (i)
                            for i in range (5, 16)],
                           range (11))
        self.assertEquals ([ranged_model.line_index_to_super (i)
                            for i in range (11)],
                           range (5, 16))
        self.assertEquals ([ranged_model.line_index_from_top (i)
                            for i in range (5, 16)],
                           range (11))
        self.assertEquals ([ranged_model.line_index_to_top (i)
                            for i in range (11)],
                           range (5, 16))

        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (11)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (11)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (5, 16)],
                           range (11))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (11)],
                           range (5, 16))

        filtered_model.add_filter (CategoryFilter ("EVEN"),
                                   Common.Data.DefaultDispatcher ())
        rows_filtered = row_list (filtered_model)
        self.assertEquals (rows_filtered, range (5, 16, 2))

        self.__dump_model (filtered_model, "filtered model")

        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (0, 11, 2)],
                           range (6))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (5, 16, 2)],
                           range (6))

        ranged_model.set_range (7, 13)
        self.__dump_model (ranged_model, "ranged model (7, 13)")
        filtered_model.super_model_changed_range ()

        self.assertEquals (row_list (ranged_model), range (7, 13))
        self.assertEquals ([ranged_model.line_index_from_super (i)
                            for i in range (7, 13)],
                           range (6))
        self.assertEquals ([ranged_model.line_index_to_super (i)
                            for i in range (6)],
                           range (7, 13))
        self.assertEquals ([ranged_model.line_index_from_top (i)
                            for i in range (7, 13)],
                           range (6))
        self.assertEquals ([ranged_model.line_index_to_top (i)
                            for i in range (6)],
                           range (7, 13))

        self.__dump_model (filtered_model, "filtered model (ranged 7, 12)")
        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (0, 6, 2)],
                           range (3))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (3)],
                           range (0, 6, 2))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (7, 12, 2)],
                           range (3))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (3)],
                           range (7, 12, 2))

        rows_filtered = row_list (filtered_model)
        self.assertEquals (rows_filtered, range (7, 13, 2))
Esempio n. 6
0
    def test_filtered_range_refilter_skip (self):

        full_model = Model ()
        ranged_model = RangeFilteredLogModel (full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset ()
        filtered_model = FilteredLogModel (ranged_model)

        row_list = self.__row_list

        filtered_model.add_filter (CategoryFilter ("EVEN"),
                                   Common.Data.DefaultDispatcher ())
        self.__dump_model (filtered_model, "filtered")

        self.assertEquals (row_list (filtered_model), range (1, 20, 2))
        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (1, 20, 2)],
                           range (10))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (10)],
                           range (1, 20, 2))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (1, 20, 2)],
                           range (10))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (10)],
                           range (1, 20, 2))

        ranged_model.set_range (1, 20)
        self.__dump_model (ranged_model, "ranged (1, 20)")
        filtered_model.super_model_changed_range ()
        self.__dump_model (filtered_model, "filtered range")

        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (0, 19, 2)],
                           range (10))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (10)],
                           range (0, 19, 2))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (1, 20, 2)],
                           range (10))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (10)],
                           range (1, 20, 2))

        ranged_model.set_range (2, 20)
        self.__dump_model (ranged_model, "ranged (2, 20)")
        filtered_model.super_model_changed_range ()
        self.__dump_model (filtered_model, "filtered range")

        self.assertEquals (row_list (filtered_model), range (3, 20, 2))
        self.assertEquals ([filtered_model.line_index_from_super (i)
                            for i in range (1, 18, 2)],
                           range (9))
        self.assertEquals ([filtered_model.line_index_to_super (i)
                            for i in range (9)],
                           range (1, 18, 2))
        self.assertEquals ([filtered_model.line_index_from_top (i)
                            for i in range (3, 20, 2)],
                           range (9))
        self.assertEquals ([filtered_model.line_index_to_top (i)
                            for i in range (9)],
                           range (3, 20, 2))
Esempio n. 7
0
    def test_filtered_range_refilter(self):

        full_model = Model()
        ranged_model = RangeFilteredLogModel(full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset()
        filtered_model = FilteredLogModel(ranged_model)

        row_list = self.__row_list
        rows = row_list(full_model)
        rows_ranged = row_list(ranged_model)
        rows_filtered = row_list(filtered_model)

        self.__dump_model(full_model, "full model")
        ## self.__dump_model (ranged_model, "ranged model")
        ## self.__dump_model (filtered_model, "filtered model")

        self.assertEquals(rows, rows_ranged)
        self.assertEquals(rows, rows_filtered)

        self.assertEquals(
            [ranged_model.line_index_from_super(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [ranged_model.line_index_to_super(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [ranged_model.line_index_from_top(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [ranged_model.line_index_to_top(i) for i in range(20)], range(20))

        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(20)],
            range(20))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(20)],
            range(20))

        ranged_model.set_range(5, 16)
        self.__dump_model(ranged_model, "ranged model (5, 16)")
        filtered_model.super_model_changed_range()

        rows_ranged = row_list(ranged_model)
        self.assertEquals(rows_ranged, range(5, 16))

        self.__dump_model(filtered_model, "filtered model (nofilter, 5, 15)")

        rows_filtered = row_list(filtered_model)
        self.assertEquals(rows_ranged, rows_filtered)

        self.assertEquals(
            [ranged_model.line_index_from_super(i) for i in range(5, 16)],
            range(11))
        self.assertEquals(
            [ranged_model.line_index_to_super(i) for i in range(11)],
            range(5, 16))
        self.assertEquals(
            [ranged_model.line_index_from_top(i) for i in range(5, 16)],
            range(11))
        self.assertEquals(
            [ranged_model.line_index_to_top(i) for i in range(11)],
            range(5, 16))

        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(11)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(11)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(5, 16)],
            range(11))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(11)],
            range(5, 16))

        filtered_model.add_filter(CategoryFilter("EVEN"),
                                  Common.Data.DefaultDispatcher())
        rows_filtered = row_list(filtered_model)
        self.assertEquals(rows_filtered, range(5, 16, 2))

        self.__dump_model(filtered_model, "filtered model")

        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(0, 11, 2)],
            range(6))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(5, 16, 2)],
            range(6))

        ranged_model.set_range(7, 13)
        self.__dump_model(ranged_model, "ranged model (7, 13)")
        filtered_model.super_model_changed_range()

        self.assertEquals(row_list(ranged_model), range(7, 13))
        self.assertEquals(
            [ranged_model.line_index_from_super(i) for i in range(7, 13)],
            range(6))
        self.assertEquals(
            [ranged_model.line_index_to_super(i) for i in range(6)],
            range(7, 13))
        self.assertEquals(
            [ranged_model.line_index_from_top(i) for i in range(7, 13)],
            range(6))
        self.assertEquals(
            [ranged_model.line_index_to_top(i) for i in range(6)],
            range(7, 13))

        self.__dump_model(filtered_model, "filtered model (ranged 7, 12)")
        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(0, 6, 2)],
            range(3))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(3)],
            range(0, 6, 2))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(7, 12, 2)],
            range(3))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(3)],
            range(7, 12, 2))

        rows_filtered = row_list(filtered_model)
        self.assertEquals(rows_filtered, range(7, 13, 2))
Esempio n. 8
0
    def test_filtered_range_refilter_skip(self):

        full_model = Model()
        ranged_model = RangeFilteredLogModel(full_model)
        # FIXME: Call to .reset should not be needed.
        ranged_model.reset()
        filtered_model = FilteredLogModel(ranged_model)

        row_list = self.__row_list

        filtered_model.add_filter(CategoryFilter("EVEN"),
                                  Common.Data.DefaultDispatcher())
        self.__dump_model(filtered_model, "filtered")

        self.assertEquals(row_list(filtered_model), range(1, 20, 2))
        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(1, 20, 2)],
            range(10))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(10)],
            range(1, 20, 2))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(1, 20, 2)],
            range(10))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(10)],
            range(1, 20, 2))

        ranged_model.set_range(1, 20)
        self.__dump_model(ranged_model, "ranged (1, 20)")
        filtered_model.super_model_changed_range()
        self.__dump_model(filtered_model, "filtered range")

        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(0, 19, 2)],
            range(10))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(10)],
            range(0, 19, 2))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(1, 20, 2)],
            range(10))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(10)],
            range(1, 20, 2))

        ranged_model.set_range(2, 20)
        self.__dump_model(ranged_model, "ranged (2, 20)")
        filtered_model.super_model_changed_range()
        self.__dump_model(filtered_model, "filtered range")

        self.assertEquals(row_list(filtered_model), range(3, 20, 2))
        self.assertEquals(
            [filtered_model.line_index_from_super(i) for i in range(1, 18, 2)],
            range(9))
        self.assertEquals(
            [filtered_model.line_index_to_super(i) for i in range(9)],
            range(1, 18, 2))
        self.assertEquals(
            [filtered_model.line_index_from_top(i) for i in range(3, 20, 2)],
            range(9))
        self.assertEquals(
            [filtered_model.line_index_to_top(i) for i in range(9)],
            range(3, 20, 2))