Пример #1
0
 def test_from_to_json(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     json_text = sub.to_json()
     new_sub = BangumiAnime.from_json(json_text)
     self.assertEqual(sub, new_sub)
     for ep, new_ep in zip(sub.eps, new_sub.eps):
         self.assertEqual(ep, new_ep)
Пример #2
0
 def test_from_to_json(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     json_text = sub.to_json()
     new_sub = BangumiAnime.from_json(json_text)
     self.assertEqual(sub, new_sub)
     for ep, new_ep in zip(sub.eps, new_sub.eps):
         self.assertEqual(ep, new_ep)
Пример #3
0
 def test_ep_colls_for_sub_from_html(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     ep_colls = (BangumiEpisodeCollection
                 .ep_colls_for_sub_from_html(sub, self._ep_html))
     c_statuses = [ep_coll.c_status for ep_coll in ep_colls]
     for c_status, c_status_expected in zip(c_statuses, self._c_statuses):
         self.assertEqual(c_status_expected, c_status)
Пример #4
0
 def test_to_collection(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with BangumiSession('*****@*****.**', '15263748') as session:
         sub_coll = sub.to_collection(session)
         sub_coll_other = session.get_sub_collection(self._id_)
         self.assertIs(session, sub_coll.session)
         self.assertEqual(sub_coll, sub_coll_other)
Пример #5
0
 def test_eps(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with self.assertRaises(TypeError):
         sub.eps = [sub]
     self.assertEqual(31, len(sub.eps))
     sub.eps = sub.eps[:26]
     self.assertEqual(26, len(sub.eps))
Пример #6
0
 def test_to_collection(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with BangumiSession('*****@*****.**', '15263748') as session:
         sub_coll = sub.to_collection(session)
         sub_coll_other = session.get_sub_collection(self._id_)
         self.assertIs(session, sub_coll.session)
         self.assertEqual(sub_coll, sub_coll_other)
Пример #7
0
 def test_eps(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with self.assertRaises(TypeError):
         sub.eps = [sub]
     self.assertEqual(31, len(sub.eps))
     sub.eps = sub.eps[:26]
     self.assertEqual(26, len(sub.eps))
Пример #8
0
 def test_from_html_with_subject(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     sub_coll = (BangumiAnimeCollection
                 .from_html_with_subject(sub, 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))
Пример #9
0
 def test_n_eps(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with self.assertRaises(ValueError):
         sub.n_eps = -1
     with self.assertRaises(ValueError):
         sub.n_eps = 'abc'
     self.assertEqual(self._n_eps, sub.n_eps)
     sub.n_eps = 10
     self.assertEqual(10, sub.n_eps)
Пример #10
0
 def test_n_eps(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     with self.assertRaises(ValueError):
         sub.n_eps = -1
     with self.assertRaises(ValueError):
         sub.n_eps = 'abc'
     self.assertEqual(self._n_eps, sub.n_eps)
     sub.n_eps = 10
     self.assertEqual(10, sub.n_eps)
Пример #11
0
 def test_from_html(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     for attr_name in ['_id_', '_title', '_ch_title', '_n_eps']:
         self.assertEqual(getattr(self, attr_name),
                          getattr(sub, attr_name))
Пример #12
0
 def test_from_html(self):
     sub = BangumiAnime.from_html(self._sub_html, self._ep_html)
     for attr_name in ['_id_', '_title', '_ch_title', '_n_eps']:
         self.assertEqual(getattr(self, attr_name), getattr(sub, attr_name))