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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import unittest
  2. from kosmorrolib.ephemerides import EphemeridesComputer
  3. from kosmorrolib.core import get_skf_objects
  4. from kosmorrolib.data import Star, Position, MoonPhase
  5. from datetime import date
  6. class EphemeridesComputerTestCase(unittest.TestCase):
  7. def test_get_ephemerides_for_aster_returns_correct_hours(self):
  8. position = Position(0, 0)
  9. position.observation_planet = get_skf_objects()['earth']
  10. star = EphemeridesComputer.get_asters_ephemerides_for_aster(Star('Sun', skyfield_name='sun'),
  11. date=date(2019, 11, 18),
  12. position=position)
  13. self.assertEqual('2019-11-18T05:41:31Z', star.ephemerides.rise_time.utc_iso())
  14. self.assertEqual('2019-11-18T11:45:02Z', star.ephemerides.culmination_time.utc_iso())
  15. self.assertEqual('2019-11-18T17:48:39Z', star.ephemerides.set_time.utc_iso())
  16. ###################################################################################################################
  17. ### MOON PHASE TESTS ###
  18. ###################################################################################################################
  19. def test_moon_phase_new_moon(self):
  20. phase = EphemeridesComputer.get_moon_phase(2019, 11, 25)
  21. self.assertEqual('WANING_CRESCENT', phase.identifier)
  22. self.assertIsNone(phase.time)
  23. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-26T')
  24. phase = EphemeridesComputer.get_moon_phase(2019, 11, 26)
  25. self.assertEqual('NEW_MOON', phase.identifier)
  26. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-12-04T')
  27. phase = EphemeridesComputer.get_moon_phase(2019, 11, 27)
  28. self.assertEqual('WAXING_CRESCENT', phase.identifier)
  29. self.assertIsNone(phase.time)
  30. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-12-04T')
  31. def test_moon_phase_first_crescent(self):
  32. phase = EphemeridesComputer.get_moon_phase(2019, 11, 3)
  33. self.assertEqual('WAXING_CRESCENT', phase.identifier)
  34. self.assertIsNone(phase.time)
  35. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-04T')
  36. phase = EphemeridesComputer.get_moon_phase(2019, 11, 4)
  37. self.assertEqual('FIRST_QUARTER', phase.identifier)
  38. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-12T')
  39. phase = EphemeridesComputer.get_moon_phase(2019, 11, 5)
  40. self.assertEqual('WAXING_GIBBOUS', phase.identifier)
  41. self.assertIsNone(phase.time)
  42. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-12T')
  43. def test_moon_phase_full_moon(self):
  44. phase = EphemeridesComputer.get_moon_phase(2019, 11, 11)
  45. self.assertEqual('WAXING_GIBBOUS', phase.identifier)
  46. self.assertIsNone(phase.time)
  47. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-12T')
  48. phase = EphemeridesComputer.get_moon_phase(2019, 11, 12)
  49. self.assertEqual('FULL_MOON', phase.identifier)
  50. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-19T')
  51. phase = EphemeridesComputer.get_moon_phase(2019, 11, 13)
  52. self.assertEqual('WANING_GIBBOUS', phase.identifier)
  53. self.assertIsNone(phase.time)
  54. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-19T')
  55. def test_moon_phase_last_quarter(self):
  56. phase = EphemeridesComputer.get_moon_phase(2019, 11, 18)
  57. self.assertEqual('WANING_GIBBOUS', phase.identifier)
  58. self.assertIsNone(phase.time)
  59. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-19T')
  60. phase = EphemeridesComputer.get_moon_phase(2019, 11, 19)
  61. self.assertEqual('LAST_QUARTER', phase.identifier)
  62. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-26T')
  63. phase = EphemeridesComputer.get_moon_phase(2019, 11, 20)
  64. self.assertEqual('WANING_CRESCENT', phase.identifier)
  65. self.assertIsNone(phase.time)
  66. self.assertRegexpMatches(phase.next_phase_date.utc_iso(), '^2019-11-26T')
  67. def test_moon_phase_prediction(self):
  68. phase = MoonPhase('NEW_MOON', None, None)
  69. self.assertEqual('First Quarter', phase.get_next_phase())
  70. phase = MoonPhase('WAXING_CRESCENT', None, None)
  71. self.assertEqual('First Quarter', phase.get_next_phase())
  72. phase = MoonPhase('FIRST_QUARTER', None, None)
  73. self.assertEqual('Full Moon', phase.get_next_phase())
  74. phase = MoonPhase('WAXING_GIBBOUS', None, None)
  75. self.assertEqual('Full Moon', phase.get_next_phase())
  76. phase = MoonPhase('FULL_MOON', None, None)
  77. self.assertEqual('Last Quarter', phase.get_next_phase())
  78. phase = MoonPhase('WANING_GIBBOUS', None, None)
  79. self.assertEqual('Last Quarter', phase.get_next_phase())
  80. phase = MoonPhase('LAST_QUARTER', None, None)
  81. self.assertEqual('New Moon', phase.get_next_phase())
  82. phase = MoonPhase('WANING_CRESCENT', None, None)
  83. self.assertEqual('New Moon', phase.get_next_phase())
  84. if __name__ == '__main__':
  85. unittest.main()