Queer European MD passionate about IT

test_seasons.py 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from seasons import format_minutes, parse_date
  2. def main():
  3. test_format_minutes()
  4. test_invalid_dates()
  5. test_known_intervals()
  6. def test_format_minutes():
  7. assert format_minutes(1) == 'One minute'
  8. assert format_minutes(2) == 'Two minutes'
  9. def test_invalid_dates():
  10. try:
  11. parse_date('91-5-9')
  12. raise Exception
  13. except Exception as e:
  14. assert isinstance(e, ValueError)
  15. try:
  16. parse_date('cacao')
  17. raise Exception
  18. except Exception as e:
  19. assert isinstance(e, ValueError)
  20. try:
  21. parse_date('1991-13-09')
  22. raise Exception
  23. except Exception as e:
  24. assert isinstance(e, ValueError)
  25. try:
  26. parse_date('1991-11-40')
  27. raise Exception
  28. except Exception as e:
  29. assert isinstance(e, ValueError)
  30. def test_known_intervals():
  31. assert format_minutes(525600) == "Five hundred twenty-five thousand, six hundred minutes"
  32. assert format_minutes(1051200) == "One million, fifty-one thousand, two hundred minutes"
  33. if __name__ == '__main__':
  34. main()