from seasons import format_minutes, parse_date


def main():
  test_format_minutes()
  test_invalid_dates()
  test_known_intervals()


def test_format_minutes():
  assert format_minutes(1) == 'One minute'
  assert format_minutes(2) == 'Two minutes'


def test_invalid_dates():
  try:
    parse_date('91-5-9')
    raise Exception
  except Exception as e:
    assert isinstance(e, ValueError)
  try:
    parse_date('cacao')
    raise Exception
  except Exception as e:
    assert isinstance(e, ValueError)
  try:
    parse_date('1991-13-09')
    raise Exception
  except Exception as e:
    assert isinstance(e, ValueError)
  try:
    parse_date('1991-11-40')
    raise Exception
  except Exception as e:
    assert isinstance(e, ValueError)


def test_known_intervals():
  assert format_minutes(525600) == "Five hundred twenty-five thousand, six hundred minutes"
  assert format_minutes(1051200) == "One million, fifty-one thousand, two hundred minutes"


if __name__ == '__main__':
  main()
