-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_julian.py
executable file
·60 lines (43 loc) · 2.02 KB
/
test_julian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import src.practical_astronomy.pa_datetime as PD
import unittest as UT
def get_julian_date(month,day,year):
return PD.greenwich_date_to_julian_date(day,month,year)
class test_julian(UT.TestCase):
def setUp(self):
self.inputMonth = 6
self.inputDay = 19.75
self.inputYear = 2009
def test_greenwich_to_julian(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
print(f"Julian Date for {self.inputMonth}/{self.inputDay}/{self.inputYear} is {julianDate}")
self.assertEqual(julianDate,2455002.25,"Conversion to Julian Date")
def test_day_of_week(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
dayOfWeek = PD.julian_date_to_weekday_name(julianDate)
print(f"The day of the week for Julian Date {julianDate} is {dayOfWeek}")
self.assertEqual(dayOfWeek,"Friday","Get Day of Week")
def test_julian_to_greenwich(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
day,month,year = PD.julian_date_to_greenwich_date(julianDate)
print(f"Converting {julianDate} back to Greenwich Date gives {month}/{day}/{year}")
self.assertEqual(month,6,"Month")
self.assertEqual(day,19.75,"Day")
self.assertEqual(year,2009,"Year")
def test_day_part(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
dayPart=PD.julian_date_day(julianDate)
print(f"The day part of {julianDate} is {dayPart}")
self.assertEqual(dayPart,19.75,"Day part")
def test_month_part(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
monthPart=PD.julian_date_month(julianDate)
print(f"The month part of {julianDate} is {monthPart}")
self.assertEqual(monthPart,6,"Month part")
def test_year_part(self):
julianDate = get_julian_date(self.inputMonth,self.inputDay,self.inputYear)
yearPart=PD.julian_date_year(julianDate)
print(f"The year part of {julianDate} is {yearPart}")
self.assertEqual(yearPart,2009,"Year part")
if __name__ == '__main__':
UT.main()