test_feed.py 877 B

123456789101112131415161718192021222324252627282930
  1. import unittest
  2. from feed import CheckFeed
  3. test_channel_id = 'UCY9z_LHm2NMRJbqKl2H3Kdw'
  4. class TestFeed(unittest.TestCase):
  5. def test_not_negative_ineger(self):
  6. with self.assertRaises(ValueError):
  7. CheckFeed(test_channel_id, -5)
  8. with self.assertRaises(ValueError):
  9. CheckFeed(test_channel_id, 0)
  10. with self.assertRaises(ValueError):
  11. CheckFeed(test_channel_id, '')
  12. def test_items_quantity(self):
  13. quantity = 7
  14. test_feed = CheckFeed(test_channel_id, quantity)
  15. self.assertEqual(len(test_feed.videos), quantity)
  16. def test_read_method_quantity(self):
  17. test_feed = CheckFeed(test_channel_id, 7)
  18. with self.assertRaises(ValueError):
  19. test_feed.read(-1)
  20. def test_nonvalid_channel_id(self):
  21. with self.assertRaises(ValueError):
  22. CheckFeed('')