Passed
Pull Request — dev (#1183)
by Patrik
04:02
created

tests.test_options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 17
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_check_invest_attributes_nonconvex() 0 10 2
A test_check_nonconvex() 0 9 2
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
            )
40
        )
41