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)
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)
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)
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)
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))
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'})
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]))
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"])
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]]))
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"])
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]})
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"})
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"]))
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']))
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)