def test_n_watched_eps(self): sub_coll = BangumiAnimeCollection.from_html(self._sub_html, self._ep_html) with self.assertRaises(ValueError): sub_coll.n_watched_eps = -1 with self.assertRaises(ValueError): sub_coll.n_watched_eps = sub_coll.subject.n_eps + 10
def test_find_ep_coll(self): sub_coll = BangumiAnimeCollection.from_html(self._sub_html, self._ep_html) self.assertEqual(sub_coll.ep_collections[0], sub_coll.find_ep_coll("519")) self.assertEqual(sub_coll.ep_collections[-1], sub_coll.find_ep_coll("ED3")) self.assertIsNone(sub_coll.find_ep_coll("ED5"))
def test_from_html(self): sub_coll = BangumiAnimeCollection.from_html(self._sub_html, self._ep_html) for name in ['_c_status', '_rating', '_tags', '_comment', '_n_watched_eps']: self.assertEqual(getattr(self, name), getattr(sub_coll, name))
def test_ep_collections(self): sub_coll = BangumiAnimeCollection.from_html(self._sub_html, self._ep_html) with self.assertRaises(TypeError): sub_coll.ep_collections = [sub_coll]
def test_from_to_json(self): sub_coll = BangumiAnimeCollection.from_html(self._sub_html, self._ep_html) json_text = sub_coll.to_json() sub_coll_new = BangumiAnimeCollection.from_json(json_text) self.assertEqual(sub_coll, sub_coll_new)