|
1 | 1 | import pandas as pd
|
2 | 2 | from datetime import datetime
|
3 |
| -from pvlib.bifacial import pvfactors_timeseries |
| 3 | +from pvlib.bifacial import pvfactors_timeseries, build, merge |
4 | 4 | from conftest import requires_pvfactors
|
5 | 5 | import pytest
|
6 | 6 |
|
@@ -107,3 +107,39 @@ def test_pvfactors_timeseries_pandas_inputs(run_parallel_calculations):
|
107 | 107 |
|
108 | 108 | pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
|
109 | 109 | 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