| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Tests of the _options module. |
||
| 2 | |||
| 3 | This file is part of project oemof (github.com/oemof/oemof). It's copyrighted |
||
| 4 | by the contributors recorded in the version control history of the file, |
||
| 5 | available from its original location oemof/tests/test_components.py |
||
| 6 | |||
| 7 | SPDX-License-Identifier: MIT |
||
| 8 | """ |
||
| 9 | |||
| 10 | import pytest |
||
| 11 | from oemof.tools import debugging |
||
| 12 | |||
| 13 | from oemof import solph |
||
| 14 | |||
| 15 | |||
| 16 | def test_check_invest_attributes_nonconvex(): |
||
| 17 | """Check error being thrown if nonconvex parameter is not of type bool""" |
||
| 18 | msg = ( |
||
| 19 | "The `nonconvex` parameter of the `Investment` class has to be of type" |
||
| 20 | + " boolean, not <class 'oemof.solph._options.NonConvex'>." |
||
| 21 | ) |
||
| 22 | with pytest.raises(AttributeError, match=msg): |
||
| 23 | solph.Flow( |
||
| 24 | nominal_capacity=solph.Investment( |
||
| 25 | maximum=1, nonconvex=solph.NonConvex() |
||
| 26 | ) |
||
| 27 | ) |
||
| 28 | |||
| 29 | |||
| 30 | def test_check_nonconvex(): |
||
| 31 | """ |
||
| 32 | Check warning being thrown if minimum and offset are zero and nonconvex |
||
| 33 | is set |
||
| 34 | """ |
||
| 35 | with pytest.warns(debugging.SuspiciousUsageWarning): |
||
| 36 | solph.Flow( |
||
| 37 | nominal_capacity=solph.Investment( |
||
| 38 | maximum=1, minimum=0, offset=0, nonconvex=True |
||
| 39 | ) |
||
| 41 |