import unittest
from app import parse_duration
class T(unittest.TestCase):
 def test_valid(self):
  self.assertEqual(parse_duration('2h 5m 9s'),7509)
  self.assertEqual(parse_duration('45m'),2700)
  self.assertEqual(parse_duration('7s'),7)
 def test_bad(self):
  for x in ['', '5m 2h', '1h 2h', 'abc', '4x']:
   with self.assertRaises(ValueError): parse_duration(x)
if __name__=='__main__': unittest.main()
