Exemplo n.º 1
0
 def test_select_and_save(self):
     b2 = Bangumi(name='test_select_and_save', update_time='Sun')
     d = b2.select()
     self.assertEqual(d, [])
     b2.save()
     ret = b2.select(one=True)
     self.assertIsInstance(ret, dict)
Exemplo n.º 2
0
    def test_update(self):
        b1 = Bangumi(name='test_update', update_time='Sun')
        b1.save()
        b1.update_time = 'Mon'
        b1.update()
        ret = b1.select(one=True)
        self.assertEqual(ret['update_time'], 'Mon')

        b1.update(data={'name': 'test666', 'update_time': 'Sat'})
        ret = b1.select(one=True)
        self.assertIsInstance(ret, dict)
Exemplo n.º 3
0
 def test_add_and_remove_followed(self):
     f = Followed(bangumi_name='test_add_and_remove_followed',
                  status=STATUS_FOLLOWED,
                  episode=6)
     f.save()
     b = Bangumi(name='test_add_and_remove_followed')
     b.save()
     bangumi_data = b.select(
         one=True,
         join='LEFT JOIN %s ON %s.bangumi_name=%s.name' %
         (Followed.table, Followed.table, Bangumi.table))
     self.assertEqual(bangumi_data['status'], STATUS_FOLLOWED)
     f.delete()
     bangumi_data = b.select(
         one=True,
         join='LEFT JOIN %s ON %s.bangumi_name=%s.name' %
         (Followed.table, Followed.table, Bangumi.table))
     self.assertEqual(bangumi_data['status'], STATUS_NORMAL)
Exemplo n.º 4
0
 def test_delete(self):
     b1 = Bangumi(name='test_delete', update_time='Sun')
     b1.save()
     self.assertEqual(b1.select(one=True)['name'], 'test_delete')
     b1.delete()
     self.assertEqual(b1.select(one=True), None)
Exemplo n.º 5
0
 def save_data(data):
     b = Bangumi(**data)
     b.save()