Skip to content

Commit 079bb48

Browse files
Add tests for merge() and build().
1 parent feb7bf3 commit 079bb48

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

pvlib/test/test_bifacial.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pandas as pd
22
from datetime import datetime
3-
from pvlib.bifacial import pvfactors_timeseries
3+
from pvlib.bifacial import pvfactors_timeseries, build, merge
44
from conftest import requires_pvfactors
55
import pytest
66

@@ -107,3 +107,39 @@ def test_pvfactors_timeseries_pandas_inputs(run_parallel_calculations):
107107

108108
pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
109109
pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
110+
111+
def test_build_1():
112+
"""Test that build correctly instantiates a dictionary, when passed a Nones
113+
for the report and pvarray arguments.
114+
"""
115+
report = None
116+
pvarray = None
117+
expected = {'total_inc_back': [], 'total_inc_front': []}
118+
assert expected == build(report, pvarray)
119+
120+
def test_merge_1():
121+
"""Test that merge correctly returns the first element of the reports
122+
argument when there is only dictionary in reports.
123+
"""
124+
test_dict = {'total_inc_back': [1,2,3], 'total_inc_front': [4,5,6]}
125+
reports = [test_dict]
126+
assert test_dict == merge(reports)
127+
128+
def test_merge_2():
129+
"""Test that merge correctly combines two dictionary reports.
130+
"""
131+
test_dict_1 = {'total_inc_back': [1,2], 'total_inc_front': [4,5]}
132+
test_dict_2 = {'total_inc_back': [3], 'total_inc_front': [6]}
133+
expected = {'total_inc_back': [1,2,3], 'total_inc_front': [4,5,6]}
134+
reports = [test_dict_1, test_dict_2]
135+
assert expected == merge(reports)
136+
137+
def test_merge_3():
138+
"""Test that merge correctly combines three dictionary reports.
139+
"""
140+
test_dict_1 = {'total_inc_back': [1], 'total_inc_front': [4]}
141+
test_dict_2 = {'total_inc_back': [2], 'total_inc_front': [5]}
142+
test_dict_3 = {'total_inc_back': [3], 'total_inc_front': [6]}
143+
expected = {'total_inc_back': [1, 2, 3], 'total_inc_front': [4, 5, 6]}
144+
reports = [test_dict_1, test_dict_2, test_dict_3]
145+
assert expected == merge(reports)

0 commit comments

Comments
 (0)