Skip to content

Commit b575cf6

Browse files
committed
add tests for __repr__() functions
1 parent c2da263 commit b575cf6

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

pvlib/test/test_location.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,10 @@ def test_get_airmass_valueerror():
160160
end='20160101T1800-0700',
161161
freq='3H')
162162
clearsky = tus.get_airmass(times, model='invalid_model')
163+
164+
def test_Location___repr__():
165+
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')
166+
assert tus.__repr__()==('Tucson: latitude=32.2, longitude=-111, '+
167+
'tz=US/Arizona, altitude=700')
168+
169+

pvlib/test/test_modelchain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,18 @@ def test_basic_chain_altitude_pressure():
220220
expected = pd.Series(np.array([ 1.15771428788e+02, -2.00000000e-02]),
221221
index=times)
222222
assert_series_equal(ac, expected)
223+
224+
225+
def test_ModelChain___repr__():
226+
system = PVSystem()
227+
location = Location(32.2, -111, altitude=700)
228+
strategy = 'south_at_latitude_tilt'
229+
230+
mc = ModelChain(system, location, orientation_strategy=strategy)
231+
232+
# the || accounts for the coercion of 'None' to None
233+
assert mc.__repr__() == ('ModelChain for: PVSystem with tilt:32.2 and '+
234+
'azimuth: 180 with Module: None and Inverter: None with '+
235+
'orientation_startegy: south_at_latitude_tilt clearsky_model:ineichen '+
236+
'transposition_model: haydavies solar_position_method: nrel_numpy '+
237+
'airmass_model: kastenyoung1989')

pvlib/test/test_pvsystem.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,21 @@ def test_PVSystem_localize_with_latlon():
480480
assert localized_system.longitude == -111
481481

482482

483+
def test_PVSystem___repr__():
484+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
485+
486+
assert system.__repr__()==('PVSystem with tilt:0 and azimuth:'+
487+
' 180 with Module: blah and Inverter: blarg')
488+
489+
490+
def test_PVSystem_localize___repr__():
491+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
492+
localized_system = system.localize(latitude=32, longitude=-111)
493+
494+
assert localized_system.__repr__()==('LocalizedPVSystem with tilt:0 and'+
495+
' azimuth: 180 with Module: blah and Inverter: blarg and Location: None:'+
496+
' latitude=32, longitude=-111, tz=UTC, altitude=0')
497+
483498
# we could retest each of the models tested above
484499
# when they are attached to LocalizedPVSystem, but
485500
# that's probably not necessary at this point.
@@ -495,3 +510,13 @@ def test_LocalizedPVSystem_creation():
495510
assert localized_system.inverter == 'blarg'
496511
assert localized_system.latitude == 32
497512
assert localized_system.longitude == -111
513+
514+
515+
def test_LocalizedPVSystem___repr__():
516+
localized_system = pvsystem.LocalizedPVSystem(latitude=32,
517+
longitude=-111,
518+
module='blah',
519+
inverter='blarg')
520+
521+
assert localized_system.__repr__()==('LocalizedPVSystem with tilt:0 and'+
522+
' azimuth: 180 with Module: blah and Inverter: blarg and Location: None')

0 commit comments

Comments
 (0)