示例#1
0
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.p2 = Pane(lib, "artist", self)
        self.p1 = Pane(lib, "genre", self.p2)
        self.last = None
        self.count = 0
示例#2
0
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.p2 = Pane(lib, "artist", self)
        self.p1 = Pane(lib, "genre", self.p2)
        self.last = None
        self.count = 0
示例#3
0
class TMultiPane(TestCase):

    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.p2 = Pane(lib, "artist", self)
        self.p1 = Pane(lib, "genre", self.p2)
        self.last = None
        self.count = 0

    def fill(self, songs):
        # this class is the final pane
        self.last = songs
        self.count += 1

    def test_inhibit(self):
        self.p2.inhibit()
        self.p1.fill(SONGS)
        self.p2.uninhibit()
        self.assertEqual(self.count, 0)

    def test_pipe_through(self):
        self.p1.fill(SONGS)
        self.assertEqual(self.last, set(SONGS))
        self.assertEqual(self.count, 1)

    def test_filter_first(self):
        VALUE = "J-Pop"
        self.p1.fill(SONGS)
        keys = self.p1.list("genre")
        self.assertTrue(VALUE in keys)
        self.p1.set_selected([VALUE], force_any=False)
        self.assertTrue(self.last)
        for song in self.last:
            self.assertEqual(song("genre"), VALUE)
        self.assertEqual(self.count, 2)

    def tearDown(self):
        self.p1.destroy()
        self.p2.destroy()
        del self.p1
        del self.p2
        config.quit()
示例#4
0
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.pane = Pane(lib, "artist")
示例#5
0
class TPane(TestCase):

    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.pane = Pane(lib, "artist")

    def tearDown(self):
        self.pane.destroy()
        del self.pane
        config.quit()

    def test_init(self):
        repr(self.pane)
        self.assertEqual(self.pane.tags, {"artist"})

    def test_add_remove_and_show(self):
        with realized(self.pane):
            self.pane.add(SONGS)
        with realized(self.pane):
            self.pane.remove(SONGS)
        self.assertFalse(self.pane.list("arist"))

    def test_matches(self):
        self.assertTrue(self.pane.matches(SONGS[0]))
        self.pane.fill(SONGS)
        selection = self.pane.get_selection()
        selection.unselect_all()
        selection.select_path(Gtk.TreePath(3))
        self.assertFalse(self.pane.matches(SONGS[1]))

    def test_fill(self):
        self.pane.fill(SONGS)

    def test_fill_selection(self):
        self.pane.fill(SONGS)

        model, paths = self.pane.get_selection().get_selected_rows()
        self.assertEqual(len(paths), 1)
        self.assertEqual(paths[0], Gtk.TreePath((0,)))

    def test_set_selected(self):
        self.pane.fill(SONGS)

        self.pane.set_selected([])
        self.assertEqual(self.pane.get_selected(), {None})

        self.pane.set_selected([], force_any=False)
        self.assertEqual(self.pane.get_selected(), set())

        keys = self.pane.list("artist")
        self.pane.set_selected(keys)
        self.assertEqual(self.pane.get_selected(), keys)

    def test_restore_string(self):
        self.pane.fill(SONGS)
        keys = self.pane.list("artist")
        self.pane.set_selected(keys)

        to_restore = self.pane.get_restore_string()
        self.pane.remove(SONGS)
        self.pane.parse_restore_string(to_restore)
        self.pane.fill(SONGS)
        self.assertEqual(self.pane.get_selected(), keys)
示例#6
0
class TMultiPane(TestCase):
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.p2 = Pane(lib, "artist", self)
        self.p1 = Pane(lib, "genre", self.p2)
        self.last = None
        self.count = 0

    def fill(self, songs):
        # this class is the final pane
        self.last = songs
        self.count += 1

    def test_inhibit(self):
        self.p2.inhibit()
        self.p1.fill(SONGS)
        self.p2.uninhibit()
        self.assertEqual(self.count, 0)

    def test_pipe_through(self):
        self.p1.fill(SONGS)
        self.assertEqual(self.last, set(SONGS))
        self.assertEqual(self.count, 1)

    def test_filter_first(self):
        VALUE = "J-Pop"
        self.p1.fill(SONGS)
        keys = self.p1.list("genre")
        self.assertTrue(VALUE in keys)
        self.p1.set_selected([VALUE], force_any=False)
        self.assertTrue(self.last)
        for song in self.last:
            self.assertEqual(song("genre"), VALUE)
        self.assertEqual(self.count, 2)

    def tearDown(self):
        self.p1.destroy()
        self.p2.destroy()
        del self.p1
        del self.p2
        config.quit()
示例#7
0
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.pane = Pane(lib, "artist")
示例#8
0
class TPane(TestCase):
    def setUp(self):
        config.init()

        lib = SongLibrary()
        self.pane = Pane(lib, "artist")

    def tearDown(self):
        self.pane.destroy()
        del self.pane
        config.quit()

    def test_init(self):
        repr(self.pane)
        self.assertEqual(self.pane.tags, set(["artist"]))

    def test_add_remove_and_show(self):
        with realized(self.pane):
            self.pane.add(SONGS)
        with realized(self.pane):
            self.pane.remove(SONGS)
        self.assertFalse(self.pane.list("arist"))

    def test_matches(self):
        self.assertTrue(self.pane.matches(SONGS[0]))
        self.pane.fill(SONGS)
        selection = self.pane.get_selection()
        selection.unselect_all()
        selection.select_path(Gtk.TreePath(3))
        self.assertFalse(self.pane.matches(SONGS[1]))

    def test_fill(self):
        self.pane.fill(SONGS)

    def test_fill_selection(self):
        self.pane.fill(SONGS)

        model, paths = self.pane.get_selection().get_selected_rows()
        self.assertEqual(len(paths), 1)
        self.assertEqual(paths[0], Gtk.TreePath((0, )))

    def test_set_selected(self):
        self.pane.fill(SONGS)

        self.pane.set_selected([])
        self.assertEqual(self.pane.get_selected(), set([None]))

        self.pane.set_selected([], force_any=False)
        self.assertEqual(self.pane.get_selected(), set())

        keys = self.pane.list("artist")
        self.pane.set_selected(keys)
        self.assertEqual(self.pane.get_selected(), keys)

    def test_restore_string(self):
        self.pane.fill(SONGS)
        keys = self.pane.list("artist")
        self.pane.set_selected(keys)

        to_restore = self.pane.get_restore_string()
        self.pane.remove(SONGS)
        self.pane.parse_restore_string(to_restore)
        self.pane.fill(SONGS)
        self.assertEqual(self.pane.get_selected(), keys)