@@ -10,75 +10,75 @@ def __init__(self, *args, **kwargs):
1010 super (TestMoon , self ).__init__ (* args , ** kwargs )
1111 self .sm = Moon ()
1212
13- # def test_returns_error_for_datetime_format_issue(self):
14- # m = Moon()
15- # self.assertRaises(ValueError, m.set_moon_datetime, "190-01-01")
13+ def test_returns_error_for_datetime_format_issue (self ):
14+ m = Moon ()
15+ self .assertRaises (ValueError , m .set_moon_datetime , "190-01-01" )
1616
17- # def test_returns_helpful_error_for_datetime_range_issue(self):
18- # m = Moon()
19- # self.assertRaisesRegex(KeyError, r"Cannot find year .* in this version "\
20- # "of the package. This package can get moons for years .* -"\
21- # " .*. Please try a different year or check for an update "\
22- # "for this package.",
23- # m.set_moon_datetime, "1900-01-01")
17+ def test_returns_helpful_error_for_datetime_range_issue (self ):
18+ m = Moon ()
19+ self .assertRaisesRegex (KeyError , r"Cannot find year .* in this version " \
20+ "of the package. This package can get moons for years .* -" \
21+ " .*. Please try a different year or check for an update " \
22+ "for this package." ,
23+ m .set_moon_datetime , "1900-01-01" )
2424
25- # def test_makes_a_moon_image_url(self):
26- # m = Moon()
27- # m.set_moon_datetime(date="2019-01-01", hour=0)
28- # assert m.url == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/"\
29- # "a004442/frames/730x730_1x1_30p/moon.0001.jpg"
25+ def test_makes_a_moon_image_url (self ):
26+ m = Moon ()
27+ m .set_moon_datetime (date = "2019-01-01" , hour = 0 )
28+ assert m .url == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/" \
29+ "a004442/frames/730x730_1x1_30p/moon.0001.jpg"
3030
31- # def test_makes_a_json_data_url(self):
32- # m = Moon()
33- # m.set_moon_datetime("2019-01-01")
34- # m.make_json_year_mooninfo_url()
35- # assert m.json_url == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/a004442/mooninfo_2019.json"
31+ def test_makes_a_json_data_url (self ):
32+ m = Moon ()
33+ m .set_moon_datetime ("2019-01-01" )
34+ m .make_json_year_mooninfo_url ()
35+ assert m .json_url == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/a004442/mooninfo_2019.json"
3636
37- # def test_gets_json_for_requested_datetime(self):
38- # m = Moon()
39- # m.set_moon_datetime(date="2019-01-01", hour=1)
40- # m.make_json_year_mooninfo_url()
41- # m.set_mooninfo_requested_year()
42- # m.set_mooninfo_requested_date()
43- # assert m.moon_datetime_info["time"] == '01 Jan 2019 01:00 UT'
37+ def test_gets_json_for_requested_datetime (self ):
38+ m = Moon ()
39+ m .set_moon_datetime (date = "2019-01-01" , hour = 1 )
40+ m .make_json_year_mooninfo_url ()
41+ m .set_mooninfo_requested_year ()
42+ m .set_mooninfo_requested_date ()
43+ assert m .moon_datetime_info ["time" ] == '01 Jan 2019 01:00 UT'
4444
45- # def test_gets_moon_image_as_numpy_array(self):
46- # m = Moon()
47- # m.set_moon_datetime("2019-01-01")
48- # m.request_moon_image()
49- # self.assertIs(type(m.image), numpy.ndarray)
45+ def test_gets_moon_image_as_numpy_array (self ):
46+ m = Moon ()
47+ m .set_moon_datetime ("2019-01-01" )
48+ m .request_moon_image ()
49+ self .assertIs (type (m .image ), numpy .ndarray )
5050
51- # def test_takes_optional_hour_arg(self):
52- # m = Moon()
53- # m.set_moon_datetime(hour=1)
54- # assert m.datetime.hour == 1
51+ def test_takes_optional_hour_arg (self ):
52+ m = Moon ()
53+ m .set_moon_datetime (hour = 1 )
54+ assert m .datetime .hour == 1
5555
56- # def test_can_get_last_hour_of_nonleap_year(self):
57- # m = Moon()
58- # m.set_moon_datetime(date="2019-12-31", hour=23)
59- # m.request_moon_image()
60- # m.make_json_year_mooninfo_url()
61- # m.set_mooninfo_requested_year()
62- # m.set_mooninfo_requested_date()
56+ def test_can_get_last_hour_of_nonleap_year (self ):
57+ m = Moon ()
58+ m .set_moon_datetime (date = "2019-12-31" , hour = 23 )
59+ m .request_moon_image ()
60+ m .make_json_year_mooninfo_url ()
61+ m .set_mooninfo_requested_year ()
62+ m .set_mooninfo_requested_date ()
6363
64- # assert m.image_src == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/a004442/"\
65- # "frames/730x730_1x1_30p/moon.8760.jpg"
64+ assert m .image_src == "https://svs.gsfc.nasa.gov/vis/a000000/a004400/a004442/" \
65+ "frames/730x730_1x1_30p/moon.8760.jpg"
6666
67- # def test_can_get_last_hour_of_year(self):
68- # m = Moon()
69- # m.set_moon_datetime(date="2020-12-31", hour=23)
70- # m.request_moon_image()
71- # assert m.image_src == "https://svs.gsfc.nasa.gov/vis/a000000/a004700/a004768/"\
72- # "frames/730x730_1x1_30p/moon.8784.jpg"
67+ def test_can_get_last_hour_of_year (self ):
68+ m = Moon ()
69+ m .set_moon_datetime (date = "2020-12-31" , hour = 23 )
70+ m .request_moon_image ()
71+ assert m .image_src == "https://svs.gsfc.nasa.gov/vis/a000000/a004700/a004768/" \
72+ "frames/730x730_1x1_30p/moon.8784.jpg"
7373
74- # def test_can_get_moon_for_2022(self):
75- # # note: this is just helpful for testing a version of `moon` where
76- # # the SVS_ID has been added to the github repo but the user
77- # # hasn't updated the package to include the new SVS_ID
78- # m = Moon()
79- # m.set_moon_datetime(date="2022-01-15")
80- # m.request_moon_image()
81- # assert m.SVS_ID_DICT["2022"] == 4955
74+ def test_can_get_moon_for_2022 (self ):
75+ # note: this is just helpful for testing a version of `moon` where
76+ # the SVS_ID has been added to the github repo but the user
77+ # hasn't updated the package to include the new SVS_ID
78+ m = Moon ()
79+ m .set_moon_datetime (date = "2022-01-15" )
80+ m .request_moon_image ()
81+ assert m .SVS_ID_DICT ["2022" ] == 4955
8282
8383 def test_gets_new_moon_info_if_another_year_requested (self ):
8484 m = Moon ()
0 commit comments