Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

130 rindas
5.6 KiB

  1. #!/usr/bin/env python3
  2. from sys import version_info as python_version
  3. from .utils import (
  4. execute,
  5. KOSMORRO,
  6. CURRENT_MOON_PHASE_PATTERN,
  7. NEXT_MOON_PHASE_PATTERN,
  8. )
  9. from datetime import date
  10. from babel.dates import format_date
  11. def test_run_without_argument():
  12. result = execute(KOSMORRO)
  13. assert result.successful
  14. stdout = result.stdout.split("\n")
  15. print(stdout)
  16. # It always starts with the current date, an empty line and the current and next Moon date:
  17. assert stdout[0] == format_date(date.today(), "full", "EN")
  18. assert stdout[1] == ""
  19. assert CURRENT_MOON_PHASE_PATTERN.match(stdout[2])
  20. assert NEXT_MOON_PHASE_PATTERN.match(stdout[3])
  21. # It always finishes with an empty line, a note about UTC timezone and an empty line:
  22. assert stdout[-3] == ""
  23. assert stdout[-2] == "Note: All the hours are given in UTC."
  24. assert stdout[-1] == ""
  25. def test_help_message():
  26. for arg in ["--help", "-h"]:
  27. result = execute(KOSMORRO + [arg])
  28. assert result.successful
  29. if python_version.major == 3 and python_version.minor < 13:
  30. assert (
  31. result.stdout
  32. == """usage: kosmorro [-h] [--version] [--format {txt,json,tex}]
  33. [--position POSITION] [--date DATE] [--timezone TIMEZONE]
  34. [--no-colors] [--output OUTPUT] [--no-graph] [--debug]
  35. [--completion COMPLETION]
  36. Compute the ephemerides and the events for a given date and a given position
  37. on Earth.
  38. options:
  39. -h, --help show this help message and exit
  40. --version, -v Show the program version
  41. --format {txt,json,tex}, -f {txt,json,tex}
  42. The format to output the information to. If not
  43. provided, the output format will be inferred from the
  44. file extension of the output file.
  45. --position POSITION, -p POSITION
  46. The observer's position on Earth, in the
  47. "{latitude},{longitude}" format. Can also be set in
  48. the KOSMORRO_POSITION environment variable.
  49. --date DATE, -d DATE The date for which the ephemerides must be calculated.
  50. Can be in the YYYY-MM-DD format or an interval in the
  51. "[+-]YyMmDd" format (with Y, M, and D numbers).
  52. Defaults to current date.
  53. --timezone TIMEZONE, -t TIMEZONE
  54. The timezone to use to display the hours. It can be
  55. either a number (e.g. 1 for UTC+1) or a timezone name
  56. (e.g. Europe/Paris). See https://en.wikipedia.org/wiki
  57. /List_of_tz_database_time_zones to find your timezone.
  58. Can also be set in the TZ environment variable.
  59. --no-colors Disable the colors in the console.
  60. --output OUTPUT, -o OUTPUT
  61. A file to export the output to. If not given, the
  62. standard output is used.
  63. --no-graph Do not generate a graph to represent the rise and set
  64. times in the LaTeX file.
  65. --debug Show debugging messages
  66. --completion COMPLETION
  67. Print a script allowing completion for your shell
  68. By default, only the events will be computed for today. To compute also the
  69. ephemerides, latitude and longitude arguments are needed.
  70. """
  71. )
  72. else:
  73. assert (
  74. result.stdout
  75. == """usage: kosmorro [-h] [--version] [--format {txt,json,tex}]
  76. [--position POSITION] [--date DATE] [--timezone TIMEZONE]
  77. [--no-colors] [--output OUTPUT] [--no-graph] [--debug]
  78. [--completion COMPLETION]
  79. Compute the ephemerides and the events for a given date and a given position
  80. on Earth.
  81. options:
  82. -h, --help show this help message and exit
  83. --version, -v Show the program version
  84. --format, -f {txt,json,tex}
  85. The format to output the information to. If not
  86. provided, the output format will be inferred from the
  87. file extension of the output file.
  88. --position, -p POSITION
  89. The observer's position on Earth, in the
  90. "{latitude},{longitude}" format. Can also be set in
  91. the KOSMORRO_POSITION environment variable.
  92. --date, -d DATE The date for which the ephemerides must be calculated.
  93. Can be in the YYYY-MM-DD format or an interval in the
  94. "[+-]YyMmDd" format (with Y, M, and D numbers).
  95. Defaults to current date.
  96. --timezone, -t TIMEZONE
  97. The timezone to use to display the hours. It can be
  98. either a number (e.g. 1 for UTC+1) or a timezone name
  99. (e.g. Europe/Paris). See https://en.wikipedia.org/wiki
  100. /List_of_tz_database_time_zones to find your timezone.
  101. Can also be set in the TZ environment variable.
  102. --no-colors Disable the colors in the console.
  103. --output, -o OUTPUT A file to export the output to. If not given, the
  104. standard output is used.
  105. --no-graph Do not generate a graph to represent the rise and set
  106. times in the LaTeX file.
  107. --debug Show debugging messages
  108. --completion COMPLETION
  109. Print a script allowing completion for your shell
  110. By default, only the events will be computed for today. To compute also the
  111. ephemerides, latitude and longitude arguments are needed.
  112. """
  113. )