コード例 #1
0
    def test_tied(self):
        p = PaneConfig("~title~artist")
        self.failUnlessEqual(p.title, "Title / Artist")
        self.failUnlessEqual(p.tags, set(["title", "artist"]))

        self.failUnlessEqual(p.format(SONGS[0]), ["three - boris"])
        self.failIf(p.has_markup)
コード例 #2
0
    def test_numeric(self):
        p = PaneConfig("~#lastplayed")
        self.failUnlessEqual(p.title, "Last Played")
        self.failUnlessEqual(p.tags, {"~#lastplayed"})

        self.failUnlessEqual(p.format(SONGS[0]), [("0", "0")])
        self.failIf(p.has_markup)
コード例 #3
0
    def test_numeric(self):
        p = PaneConfig("~#lastplayed")
        self.failUnlessEqual(p.title, "Last Played")
        self.failUnlessEqual(p.tags, set(["~#lastplayed"]))

        self.failUnlessEqual(p.format(SONGS[0]), ["0"])
        self.failIf(p.has_markup)
コード例 #4
0
    def test_tied(self):
        p = PaneConfig("~title~artist")
        self.failUnlessEqual(p.title, "Title / Artist")
        self.failUnlessEqual(p.tags, {"title", "artist"})

        self.failUnlessEqual(p.format(SONGS[0]), ["three - boris"])
        self.failIf(p.has_markup)
コード例 #5
0
    def test_tag(self):
        p = PaneConfig("title")
        self.failUnlessEqual(p.title, "Title")
        self.failUnlessEqual(p.tags, {"title"})

        self.failUnlessEqual(p.format(SONGS[0]), [("three", "three")])
        self.failUnless(str(len(ALBUM.songs)) in p.format_display(ALBUM))
        self.failIf(p.has_markup)
コード例 #6
0
    def test_tag(self):
        p = PaneConfig("title")
        self.failUnlessEqual(p.title, "Title")
        self.failUnlessEqual(p.tags, set(["title"]))

        self.failUnlessEqual(p.format(SONGS[0]), ["three"])
        self.failUnless(str(len(ALBUM.songs)) in p.format_display(ALBUM))
        self.failIf(p.has_markup)
コード例 #7
0
    def test_tied(self):
        p = PaneConfig("~title~artist")
        self.failUnlessEqual(p.title, "Title / Artist")
        self.failUnlessEqual(p.tags, {"title", "artist"})

        self.failUnlessEqual(p.format(SONGS[0]), [("three", "three"),
                                                  ("boris", "boris")])
        self.failIf(p.has_markup)
コード例 #8
0
    def test_numeric(self):
        a_date_format = "%Y-%m-%d"
        config.set("settings", "datecolumn_timestamp_format", a_date_format)
        p = PaneConfig("~#lastplayed")
        self.failUnlessEqual(p.title, "Last Played")
        self.failUnlessEqual(p.tags, {"~#lastplayed"})

        zero_date = format_date(0, a_date_format)
        self.failUnlessEqual(p.format(SONGS[0]), [(zero_date, zero_date)])
        self.failIf(p.has_markup)
コード例 #9
0
    def test_list(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)

        self.assertEqual(m.list("artist"), set(["boris", "mu", "piman", ""]))

        conf = PaneConfig("<artist><foo>")
        m = PaneModel(conf)
        m.add_songs(SONGS)

        self.assertEqual(m.list("artist"), set(["boris", "mu", "piman"]))
        self.assertEqual(set(m.list("foo")), set(['nope', 'bar', 'quux']))
コード例 #10
0
    def test_group(self):
        p = PaneConfig("a\:b:<title>")
        self.failUnlessEqual(p.title, "A:B")
        self.failUnlessEqual(set(p.format_display(ALBUM).split(", ")),
                             set(["one", "two", "three", "four", "xxx"]))

        p = PaneConfig("foo:~#lastplayed")
        self.failUnlessEqual(p.format_display(ALBUM), "0")

        p = PaneConfig("foo:title")
        self.failUnlessEqual(set(p.format_display(ALBUM).split(", ")),
                             set(["one", "two", "three", "four", "xxx"]))
コード例 #11
0
    def test_add_songs(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)
        self.assertTrue(isinstance(m[0][0], AllEntry))
        self.assertTrue(isinstance(m[-1][0], UnknownEntry))
        self.assertEqual(len(m), len(SONGS) + 1 - 1)

        m.add_songs([])
        self._verify_model(m)

        m2 = PaneModel(conf)
        for song in SONGS:
            m2.add_songs([song])
            self._verify_model(m)

        self.assertEqual(len(m), len(m2))
        for e1, e2 in zip(m.itervalues(), m2.itervalues()):
            self.assertEqual(e1.key, e2.key)

        m3 = PaneModel(conf)
        for song in reversed(SONGS):
            m3.add_songs([song])
            self._verify_model(m)

        self.assertEqual(len(m), len(m3))
        for e1, e2 in zip(m.itervalues(), m3.itervalues()):
            self.assertEqual(e1.key, e2.key)
コード例 #12
0
 def test_remove_steps(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     for song in SONGS:
         m.remove_songs([song], True)
         self._verify_model(m)
コード例 #13
0
 def test_add_unknown_first(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs([UNKNOWN_ARTIST])
     self._verify_model(m)
     m.add_songs(SONGS)
     self._verify_model(m)
コード例 #14
0
 def test_all(self):
     entry = AllEntry()
     conf = PaneConfig("title:artist")
     self.assertFalse(entry.get_count_text(conf))
     entry.get_text(conf)
     self.assertEqual(list(entry.songs), [])
     self.assertFalse(entry.contains_text(""))
     repr(entry)
コード例 #15
0
 def test_add_songs_double(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     self._verify_model(m)
     m.add_songs(SONGS)
     self._verify_model(m)
     self.assertEqual(len(m), len(SONGS) + 1 - 1)
コード例 #16
0
 def test_songs(self):
     entry = SongsEntry("key", SONGS)
     self.assertEqual(entry.key, "key")
     conf = PaneConfig("title:artist")
     self.assertTrue("boris" in entry.get_count_text(conf))
     self.assertEqual(entry.get_text(conf), (False, "key"))
     self.assertTrue(entry.contains_text("key"))
     repr(entry)
コード例 #17
0
 def test_remove_songs_remove_rows(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     length = len(m)
     m.remove_songs(SONGS, True)
     self._verify_model(m)
     self.assertNotEqual(length, len(m))
     self.assertEqual(len(m), 0)
コード例 #18
0
 def test_remove_songs_keep_rows(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     length = len(m)
     m.remove_songs(SONGS, False)
     self._verify_model(m)
     self.assertEqual(length, len(m))
     self.assertFalse(m.get_songs([r.path for r in m]))
コード例 #19
0
 def test_unknown(self):
     entry = UnknownEntry(SONGS)
     conf = PaneConfig("title:artist")
     self.assertEqual(entry.songs, set(SONGS))
     self.assertEqual(entry.key, "")
     self.assertFalse(entry.contains_text(""))
     self.assertTrue(SONGS[0]("artist") in entry.get_count_text(conf))
     entry.get_text(conf)
     repr(entry)
コード例 #20
0
    def test_get_keys_by_tag(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)

        self.assertEqual(m.get_keys_by_tag("title", ["three"]), ["boris"])
        self.assertEqual(m.get_keys_by_tag("nope", ["foo", ""]), [""])

        self.assertEqual(m.get_keys_by_tag("artist", ["piman", "foo"]),
                         ["piman"])
コード例 #21
0
    def test_matches(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)
        self.assertFalse(m.matches([], SONGS[0]))
        self.assertTrue(m.matches([0], SONGS[0]))
        self.assertTrue(m.matches([1], SONGS[0]))
        self.assertFalse(m.matches([2], SONGS[0]))

        m.add_songs([UNKNOWN_ARTIST])
        self._verify_model(m)
        self.assertTrue(m.matches([len(m) - 1], UNKNOWN_ARTIST))
コード例 #22
0
    def test_get_songs(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)

        # get none
        self.assertEqual(m.get_songs([]), set())

        # get all
        self.assertEqual(len(m.get_songs([0])), len(SONGS))
        self.assertEqual(len(m.get_songs([0, 1])), len(SONGS))

        # get one
        self.assertEqual(m.get_songs([1]), set([SONGS[0]]))
コード例 #23
0
    def test_group(self):
        p = PaneConfig(r"a\:b:<title>")
        self.failUnlessEqual(p.title, "A:B")
        self.failUnlessEqual(set(p.format_display(ALBUM).split(", ")),
                             {"one", "two", "three", "four", "xxx"})

        p = PaneConfig("foo:~#lastplayed")
        self.failUnlessEqual(p.format_display(ALBUM), "0")

        p = PaneConfig("foo:title")
        self.failUnlessEqual(set(p.format_display(ALBUM).split(", ")),
                             {"one", "two", "three", "four", "xxx"})
コード例 #24
0
 def test_pattern(self):
     p = PaneConfig("<foo>")
     self.failUnlessEqual(p.title, "Foo")
     self.failUnlessEqual(p.tags, set(["foo"]))
     self.failUnless(p.has_markup)
コード例 #25
0
 def test_condition(self):
     p = PaneConfig("<foo|a <bar>|quux>")
     self.failUnlessEqual(p.title, "a Bar")
     self.failUnlessEqual(p.tags, set(["bar"]))
     self.failUnless(p.has_markup)
コード例 #26
0
 def test_get_keys(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     self.assertEqual(m.get_keys([]), set([]))
     self.assertEqual(m.get_keys([0, 1]), set([None, "boris"]))
コード例 #27
0
 def test_songs_markup(self):
     entry = SongsEntry("key", SONGS)
     conf = PaneConfig("<title>")
     self.assertEqual(entry.get_text(conf), (True, "key"))