No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

124 líneas
5.4 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. Compute the ephemerides and the events for a given date and a given position
  36. on Earth.
  37. options:
  38. -h, --help show this help message and exit
  39. --version, -v Show the program version
  40. --format {txt,json,tex}, -f {txt,json,tex}
  41. The format to output the information to. If not
  42. provided, the output format will be inferred from the
  43. file extension of the output file.
  44. --position POSITION, -p POSITION
  45. The observer's position on Earth, in the
  46. "{latitude},{longitude}" format. Can also be set in
  47. the KOSMORRO_POSITION environment variable.
  48. --date DATE, -d DATE The date for which the ephemerides must be calculated.
  49. Can be in the YYYY-MM-DD format or an interval in the
  50. "[+-]YyMmDd" format (with Y, M, and D numbers).
  51. Defaults to current date.
  52. --timezone TIMEZONE, -t TIMEZONE
  53. The timezone to use to display the hours. It can be
  54. either a number (e.g. 1 for UTC+1) or a timezone name
  55. (e.g. Europe/Paris). See https://en.wikipedia.org/wiki
  56. /List_of_tz_database_time_zones to find your timezone.
  57. Can also be set in the TZ environment variable.
  58. --no-colors Disable the colors in the console.
  59. --output OUTPUT, -o OUTPUT
  60. A file to export the output to. If not given, the
  61. standard output is used.
  62. --no-graph Do not generate a graph to represent the rise and set
  63. times in the LaTeX file.
  64. --debug Show debugging messages
  65. By default, only the events will be computed for today. To compute also the
  66. ephemerides, latitude and longitude arguments are needed.
  67. """
  68. )
  69. else:
  70. assert (
  71. result.stdout
  72. == """usage: kosmorro [-h] [--version] [--format {txt,json,tex}]
  73. [--position POSITION] [--date DATE] [--timezone TIMEZONE]
  74. [--no-colors] [--output OUTPUT] [--no-graph] [--debug]
  75. Compute the ephemerides and the events for a given date and a given position
  76. on Earth.
  77. options:
  78. -h, --help show this help message and exit
  79. --version, -v Show the program version
  80. --format, -f {txt,json,tex}
  81. The format to output the information to. If not
  82. provided, the output format will be inferred from the
  83. file extension of the output file.
  84. --position, -p POSITION
  85. The observer's position on Earth, in the
  86. "{latitude},{longitude}" format. Can also be set in
  87. the KOSMORRO_POSITION environment variable.
  88. --date, -d DATE The date for which the ephemerides must be calculated.
  89. Can be in the YYYY-MM-DD format or an interval in the
  90. "[+-]YyMmDd" format (with Y, M, and D numbers).
  91. Defaults to current date.
  92. --timezone, -t TIMEZONE
  93. The timezone to use to display the hours. It can be
  94. either a number (e.g. 1 for UTC+1) or a timezone name
  95. (e.g. Europe/Paris). See https://en.wikipedia.org/wiki
  96. /List_of_tz_database_time_zones to find your timezone.
  97. Can also be set in the TZ environment variable.
  98. --no-colors Disable the colors in the console.
  99. --output, -o OUTPUT A file to export the output to. If not given, the
  100. standard output is used.
  101. --no-graph Do not generate a graph to represent the rise and set
  102. times in the LaTeX file.
  103. --debug Show debugging messages
  104. By default, only the events will be computed for today. To compute also the
  105. ephemerides, latitude and longitude arguments are needed.
  106. """
  107. )