@@ -28,6 +28,10 @@ def test_construction(self):
28
28
with self .assertRaises (ValueError ):
29
29
Angular (degrees = 180 , radians = 2 * 3.14 )
30
30
31
+ def test_string (self ):
32
+ a = Angular (degrees = 1 )
33
+ self .assertIsInstance (str (a ), str )
34
+
31
35
32
36
class TestDayOfYear (TestCase ):
33
37
@@ -107,6 +111,10 @@ def test_example_5_6_1(self):
107
111
standard_meridian = Angular (degrees = 90 )
108
112
self .assertAlmostEqual (local_civil_time (dt , dst_on , longitude , standard_meridian ), 9.67 , delta = 0.01 )
109
113
114
+ def test_bad_arguments (self ):
115
+ with self .assertRaises (ValueError ):
116
+ local_civil_time (datetime .now (), True , Angular (), Angular ())
117
+
110
118
111
119
class TestLocalSolarTime (TestCase ):
112
120
@@ -118,6 +126,10 @@ def test_example_5_6_1(self):
118
126
standard_meridian = Angular (degrees = 90 )
119
127
self .assertAlmostEqual (local_solar_time (dt , dst_on , longitude , standard_meridian ), 9.43 , delta = 0.01 )
120
128
129
+ def test_bad_arguments (self ):
130
+ with self .assertRaises (ValueError ):
131
+ local_solar_time (datetime .now (), True , Angular (), Angular ())
132
+
121
133
122
134
class TestHourAngle (TestCase ):
123
135
@@ -142,6 +154,10 @@ def test_solar_noon(self):
142
154
standard_meridian = Angular (degrees = 90 )
143
155
self .assertAlmostEqual (hour_angle (dt , dst_on , longitude , standard_meridian ).degrees , 0 , delta = 0.1 )
144
156
157
+ def test_bad_arguments (self ):
158
+ with self .assertRaises (ValueError ):
159
+ hour_angle (datetime .now (), True , Angular (), Angular ())
160
+
145
161
146
162
class TestAltitudeAngle (TestCase ):
147
163
@@ -152,8 +168,13 @@ def test_example_5_6_2(self):
152
168
longitude = Angular (degrees = 85 )
153
169
standard_meridian = Angular (degrees = 90 )
154
170
latitude = Angular (degrees = 40 )
155
- self .assertAlmostEqual (altitude_angle (dt , dst_on , longitude , standard_meridian , latitude ).degrees , 49.7 ,
156
- delta = 0.1 )
171
+ self .assertAlmostEqual (
172
+ altitude_angle (dt , dst_on , longitude , standard_meridian , latitude ).degrees , 49.7 , delta = 0.1
173
+ )
174
+
175
+ def test_bad_arguments (self ):
176
+ with self .assertRaises (ValueError ):
177
+ altitude_angle (datetime .now (), True , Angular (), Angular (), Angular ())
157
178
158
179
159
180
class TestAzimuthAngle (TestCase ):
@@ -170,6 +191,16 @@ def test_example_5_6_2(self):
170
191
self .assertAlmostEqual (azimuth_angle (dt , dst_on , longitude , standard_meridian , latitude ).degrees ,
171
192
expected_azimuth_from_north , delta = 0.1 )
172
193
194
+ # how about an afternoon one?
195
+ def test_afternoon (self ):
196
+ dt = datetime (2001 , 7 , 21 , 16 , 00 , 00 )
197
+ dst_on = True
198
+ longitude = Angular (degrees = 85 )
199
+ standard_meridian = Angular (degrees = 90 )
200
+ latitude = Angular (degrees = 40 )
201
+ # I just made up this example to ensure the code path works, so I'm not validating it against a value
202
+ self .assertTrue (azimuth_angle (dt , dst_on , longitude , standard_meridian , latitude ).valued )
203
+
173
204
# test one with the sun down to get a null-ish response
174
205
def test_sun_is_down (self ):
175
206
dt = datetime (2001 , 3 , 21 , 22 , 00 , 00 )
@@ -179,10 +210,14 @@ def test_sun_is_down(self):
179
210
latitude = Angular (degrees = 40 )
180
211
self .assertFalse (azimuth_angle (dt , dst_on , longitude , standard_meridian , latitude ).valued )
181
212
213
+ def test_bad_arguments (self ):
214
+ with self .assertRaises (ValueError ):
215
+ azimuth_angle (datetime .now (), True , Angular (), Angular (), Angular ())
216
+
182
217
183
218
class TestWallAzimuthAngle (TestCase ):
184
219
185
- # test east facing wall where the solar_angles azimuth is known from a prior unit test
220
+ # test south? facing wall where the solar_angles azimuth is known from a prior unit test
186
221
def test_gamma_south_facing (self ):
187
222
dt = datetime (2001 , 7 , 21 , 10 , 00 , 00 )
188
223
dst_on = True
@@ -198,6 +233,16 @@ def test_gamma_south_facing(self):
198
233
delta = 0.1
199
234
)
200
235
236
+ # test north facing wall where the azimuth should be behind the wall
237
+ def test_gamma_north_facing (self ):
238
+ dt = datetime (2001 , 7 , 21 , 10 , 00 , 00 )
239
+ dst_on = True
240
+ longitude = Angular (degrees = 85 )
241
+ standard_meridian = Angular (degrees = 90 )
242
+ latitude = Angular (degrees = 40 )
243
+ wall_normal = Angular (degrees = 270 )
244
+ self .assertFalse (wall_azimuth_angle (dt , dst_on , longitude , standard_meridian , latitude , wall_normal ).valued )
245
+
201
246
# test one with the sun down to get a null-ish response
202
247
def test_sun_is_down (self ):
203
248
dt = datetime (2001 , 3 , 21 , 22 , 00 , 00 )
@@ -208,6 +253,10 @@ def test_sun_is_down(self):
208
253
wall_normal = Angular (degrees = 90 )
209
254
self .assertFalse (wall_azimuth_angle (dt , dst_on , longitude , standard_meridian , latitude , wall_normal ).valued )
210
255
256
+ def test_bad_arguments (self ):
257
+ with self .assertRaises (ValueError ):
258
+ wall_azimuth_angle (datetime .now (), True , Angular (), Angular (), Angular (), Angular ())
259
+
211
260
212
261
class TestSolarAngleOfIncidence (TestCase ):
213
262
@@ -252,6 +301,10 @@ def test_sun_is_down(self):
252
301
solar_angle_of_incidence (dt , dst_on , longitude , standard_meridian , latitude , wall_normal ).valued
253
302
)
254
303
304
+ def test_bad_arguments (self ):
305
+ with self .assertRaises (ValueError ):
306
+ solar_angle_of_incidence (datetime .now (), True , Angular (), Angular (), Angular (), Angular ())
307
+
255
308
256
309
class TestRadiationOnSurface (TestCase ):
257
310
@@ -267,3 +320,9 @@ def test_direct_radiation_on_surface_south_facing(self):
267
320
self .assertAlmostEqual (
268
321
direct_radiation_on_surface (dt , dst_on , longitude , standard_meridian , latitude , wall_normal , insolation ),
269
322
insolation * cos (theta ), delta = 0.1 )
323
+
324
+ def test_bad_arguments (self ):
325
+ with self .assertRaises (ValueError ):
326
+ direct_radiation_on_surface (
327
+ datetime .now (), True , Angular (), Angular (), Angular (), Angular (), 1000
328
+ )
0 commit comments