選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

34 行
1.3 KiB

  1. import unittest
  2. from datetime import date
  3. from kosmorrolib import events
  4. from kosmorrolib.data import Event
  5. from kosmorrolib.core import get_timescale
  6. class MyTestCase(unittest.TestCase):
  7. def test_event_only_accepts_valid_values(self):
  8. with self.assertRaises(ValueError):
  9. Event('SUPERNOVA', None, get_timescale().now())
  10. def test_find_oppositions(self):
  11. # Test case: Mars opposition
  12. # Source of the information: https://promenade.imcce.fr/en/pages6/887.html#mar
  13. o1 = (events.search_events(date(2020, 10, 13)), '^2020-10-13T23:25')
  14. o2 = (events.search_events(date(2022, 12, 8)), '^2022-12-08T05:41')
  15. o3 = (events.search_events(date(2025, 1, 16)), '^2025-01-16T02:38')
  16. o4 = (events.search_events(date(2027, 2, 19)), '^2027-02-19T15:50')
  17. for (o, expected_date) in [o1, o2, o3, o4]:
  18. self.assertEqual(1, len(o), 'Expected 1 event for %s, got %d' % (expected_date, len(o)))
  19. self.assertEqual('OPPOSITION', o[0].event_type)
  20. self.assertEqual('MARS', o[0].object.skyfield_name)
  21. self.assertRegex(o[0].start_time.utc_iso(), expected_date)
  22. self.assertIsNone(o[0].end_time)
  23. self.assertEqual('Mars is in opposition', o[0].get_description())
  24. if __name__ == '__main__':
  25. unittest.main()