Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

65 строки
2.0 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 (
  9. result.stdout
  10. == """Monday, January 27, 2020
  11. New Moon
  12. First Quarter on Sunday, February 2, 2020 at 1:41 AM
  13. Expected events:
  14. 8:00 PM Venus and Neptune are in conjunction
  15. Note: All the hours are given in UTC.
  16. """
  17. )
  18. def test_with_incorrect_date_values():
  19. value = "yolo-yo-lo"
  20. for arg in [["-d", value], ["--date", value], [f"-d{value}"]]:
  21. result = execute(KOSMORRO + arg)
  22. assert not result.successful
  23. assert (
  24. result.stderr
  25. == f"The date {value} does not match the required YYYY-MM-DD format or the offset format.\n"
  26. )
  27. value = "2020-13-32"
  28. for arg in [["-d", value], ["--date", value], [f"-d{value}"]]:
  29. result = execute(KOSMORRO + arg)
  30. assert not result.successful
  31. assert (
  32. result.stderr
  33. == f"The date {value} is not valid: month must be in 1..12{", not 13" if python_version.minor >= 14 else ""}\n"
  34. )
  35. def test_with_out_of_range_dates():
  36. for arg in [["-d", "1789-05-05"], ["-d", "3000-01-01"]]:
  37. result = execute(KOSMORRO + arg)
  38. assert not result.successful
  39. assert (
  40. result.stderr
  41. == "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"
  42. )
  43. def test_with_out_of_range_dates_for_moon_phase_only():
  44. for arg in [["-d", "1899-07-30"], ["-d", "2053-10-06"]]:
  45. result = execute(KOSMORRO + arg)
  46. assert result.successful
  47. assert (
  48. result.stderr
  49. == "Moon phase can only be computed between August 9, 1899 and September 26, 2053\n"
  50. )