Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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))
Пример #6
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))
Пример #7
0
    def test_list(self):
        conf = PaneConfig("artist")
        m = PaneModel(conf)
        m.add_songs(SONGS)

        self.assertEqual(m.list("artist"), {"boris", "mu", "piman", ""})

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

        self.assertEqual(m.list("artist"), {"boris", "mu", "piman"})
        self.assertEqual(set(m.list("foo")), {'nope', 'bar', 'quux'})
Пример #8
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]))
Пример #9
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"])
Пример #10
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]]))
Пример #11
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)
Пример #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_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)
Пример #14
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]))
Пример #15
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)
Пример #16
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"])
Пример #17
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]), {SONGS[0]})
Пример #18
0
 def test_get_keys(self):
     conf = PaneConfig("artist")
     m = PaneModel(conf)
     m.add_songs(SONGS)
     self.assertFalse(m.get_keys([]))
     self.assertEqual(m.get_keys([0, 1]), {None, "boris"})
Пример #19
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"]))
Пример #20
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']))
Пример #21
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)
Пример #22
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)