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.
 
 
 
 

169 lines
4.7 KiB

  1. #!/usr/bin/env python3
  2. from .test_utils import (
  3. execute,
  4. KOSMORRO,
  5. )
  6. from os import path
  7. def test_json_output():
  8. result = execute(
  9. KOSMORRO + ["--position=50.5876,3.0624", "-d2020-01-27", "--format=json"]
  10. )
  11. assert result.is_successful()
  12. assert (
  13. result.stdout
  14. == """{
  15. "ephemerides": [
  16. {
  17. "object": {
  18. "identifier": "SUN",
  19. "type": "STAR",
  20. "radius": 696342
  21. },
  22. "rise_time": "2020-01-27T07:31:00",
  23. "culmination_time": "2020-01-27T12:01:00",
  24. "set_time": "2020-01-27T16:30:00"
  25. },
  26. {
  27. "object": {
  28. "identifier": "MOON",
  29. "type": "SATELLITE",
  30. "radius": 1737.4
  31. },
  32. "rise_time": "2020-01-27T09:06:00",
  33. "culmination_time": "2020-01-27T14:09:00",
  34. "set_time": "2020-01-27T19:13:00"
  35. },
  36. {
  37. "object": {
  38. "identifier": "MERCURY",
  39. "type": "PLANET",
  40. "radius": 2439.7
  41. },
  42. "rise_time": "2020-01-27T08:10:00",
  43. "culmination_time": "2020-01-27T12:49:00",
  44. "set_time": "2020-01-27T17:28:00"
  45. },
  46. {
  47. "object": {
  48. "identifier": "VENUS",
  49. "type": "PLANET",
  50. "radius": 6051.8
  51. },
  52. "rise_time": "2020-01-27T09:01:00",
  53. "culmination_time": "2020-01-27T14:35:00",
  54. "set_time": "2020-01-27T20:10:00"
  55. },
  56. {
  57. "object": {
  58. "identifier": "MARS",
  59. "type": "PLANET",
  60. "radius": 3396.2
  61. },
  62. "rise_time": "2020-01-27T04:19:00",
  63. "culmination_time": "2020-01-27T08:23:00",
  64. "set_time": "2020-01-27T12:28:00"
  65. },
  66. {
  67. "object": {
  68. "identifier": "JUPITER",
  69. "type": "PLANET",
  70. "radius": 71492
  71. },
  72. "rise_time": "2020-01-27T06:15:00",
  73. "culmination_time": "2020-01-27T10:18:00",
  74. "set_time": "2020-01-27T14:21:00"
  75. },
  76. {
  77. "object": {
  78. "identifier": "SATURN",
  79. "type": "PLANET",
  80. "radius": 60268
  81. },
  82. "rise_time": "2020-01-27T06:56:00",
  83. "culmination_time": "2020-01-27T11:09:00",
  84. "set_time": "2020-01-27T15:22:00"
  85. },
  86. {
  87. "object": {
  88. "identifier": "URANUS",
  89. "type": "PLANET",
  90. "radius": 25559
  91. },
  92. "rise_time": "2020-01-27T10:21:00",
  93. "culmination_time": "2020-01-27T17:25:00",
  94. "set_time": "2020-01-27T00:33:00"
  95. },
  96. {
  97. "object": {
  98. "identifier": "NEPTUNE",
  99. "type": "PLANET",
  100. "radius": 24764
  101. },
  102. "rise_time": "2020-01-27T09:01:00",
  103. "culmination_time": "2020-01-27T14:36:00",
  104. "set_time": "2020-01-27T20:10:00"
  105. },
  106. {
  107. "object": {
  108. "identifier": "PLUTO",
  109. "type": "PLANET",
  110. "radius": 1185
  111. },
  112. "rise_time": "2020-01-27T06:57:00",
  113. "culmination_time": "2020-01-27T11:04:00",
  114. "set_time": "2020-01-27T15:11:00"
  115. }
  116. ],
  117. "moon_phase": {
  118. "phase": "NEW_MOON",
  119. "time": "2020-01-24T21:41:59.705921+00:00",
  120. "next": {
  121. "phase": "FIRST_QUARTER",
  122. "time": "2020-02-02T01:41:40.282275+00:00"
  123. }
  124. },
  125. "events": [
  126. {
  127. "objects": [
  128. {
  129. "identifier": "VENUS",
  130. "type": "PLANET",
  131. "radius": 6051.8
  132. },
  133. {
  134. "identifier": "NEPTUNE",
  135. "type": "PLANET",
  136. "radius": 24764
  137. }
  138. ],
  139. "EventType": "CONJUNCTION",
  140. "starts_at": "2020-01-27T20:00:23.242750+00:00",
  141. "ends_at": null,
  142. "details": null
  143. }
  144. ]
  145. }
  146. """
  147. )
  148. def test_latex_output():
  149. result = execute(
  150. KOSMORRO + ["--position=50.5876,3.0624", "-d2020-01-27", "--format=tex"]
  151. )
  152. assert result.successful
  153. with open(
  154. path.join(path.dirname(__file__), "outputs", "2020-01-27-with-position.tex")
  155. ) as expected_output:
  156. expected_output = expected_output.read().replace(
  157. "__PROJECT_PATH__",
  158. path.join(path.dirname(path.dirname(__file__)), "kosmorro"),
  159. )
  160. assert result.stdout == expected_output