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.

dates.py 1.5 KiB

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