You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

62 regels
1.9 KiB

  1. #!/usr/bin/env python3
  2. from sys import version_info as python_version
  3. from .utils import execute, KOSMORRO
  4. def test_with_date():
  5. for arg in [["-d", "2020-01-27"], ["--date", "2020-01-27"], ["-d2020-01-27"]]:
  6. result = execute(KOSMORRO + arg)
  7. assert result.successful
  8. assert result.stdout == """Monday, January 27, 2020
  9. New Moon
  10. First Quarter on Sunday, February 2, 2020 at 1:41 AM
  11. Expected events:
  12. 8:00 PM Venus and Neptune are in conjunction
  13. Note: All the hours are given in UTC.
  14. """
  15. def test_with_incorrect_date_values():
  16. value = "yolo-yo-lo"
  17. for arg in [["-d", value], ["--date", value], [f"-d{value}"]]:
  18. result = execute(KOSMORRO + arg)
  19. assert not result.successful
  20. assert (
  21. result.stderr
  22. == f"The date {value} does not match the required YYYY-MM-DD format or the offset format.\n"
  23. )
  24. value = "2020-13-32"
  25. for arg in [["-d", value], ["--date", value], [f"-d{value}"]]:
  26. result = execute(KOSMORRO + arg)
  27. assert not result.successful
  28. assert (
  29. result.stderr
  30. == f"The date {value} is not valid: month must be in 1..12{", not 13" if python_version.minor >= 14 else ""}\n"
  31. )
  32. def test_with_out_of_range_dates():
  33. for arg in [["-d", "1789-05-05"], ["-d", "3000-01-01"]]:
  34. result = execute(KOSMORRO + arg)
  35. assert not result.successful
  36. assert (
  37. result.stderr
  38. == "Moon phase can only be computed between August 9, 1899 and September 26, 2053\nThe date must be between July 28, 1899 and October 8, 2053\n"
  39. )
  40. def test_with_out_of_range_dates_for_moon_phase_only():
  41. for arg in [["-d", "1899-07-30"], ["-d", "2053-10-06"]]:
  42. result = execute(KOSMORRO + arg)
  43. assert result.successful
  44. assert (
  45. result.stderr
  46. == "Moon phase can only be computed between August 9, 1899 and September 26, 2053\n"
  47. )