forked from open-atmos/PyPartMC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_env_state.py
109 lines (83 loc) · 2.95 KB
/
test_env_state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
####################################################################################################
# This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
# Copyright (C) 2022-2024 University of Illinois Urbana-Champaign #
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
####################################################################################################
import gc
import pytest
import PyPartMC as ppmc
from PyPartMC import si
from .common import ENV_STATE_CTOR_ARG_MINIMAL
from .test_aero_data import AERO_DATA_CTOR_ARG_MINIMAL
from .test_gas_data import GAS_DATA_CTOR_ARG_MINIMAL
from .test_scenario import SCENARIO_CTOR_ARG_MINIMAL
ENV_STATE_CTOR_ARG_HIGH_RH = {**ENV_STATE_CTOR_ARG_MINIMAL}
ENV_STATE_CTOR_ARG_HIGH_RH["rel_humidity"] = 0.95
class TestEnvState:
@staticmethod
@pytest.mark.parametrize("ctor_arg", (ENV_STATE_CTOR_ARG_MINIMAL,))
def test_ctor(ctor_arg):
# arrange
pass
# act
sut = ppmc.EnvState(ctor_arg)
# assert
assert sut is not None
@staticmethod
def test_dtor():
# arrange
sut = ppmc.EnvState( # pylint: disable=unused-variable
ENV_STATE_CTOR_ARG_MINIMAL
)
gc.collect()
# act
sut = None
gc.collect()
# assert
pass
@staticmethod
def test_height():
# arrange
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
value = 1
# act
sut.height = value
# assert
assert value == sut.height
@staticmethod
def test_pressure():
# arrange
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
value = 101325
# act
sut.pressure = value
# assert
assert value == sut.pressure
@staticmethod
def test_humidity_ctor():
# arrange and act
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
# assert
assert ENV_STATE_CTOR_ARG_MINIMAL["rel_humidity"] == sut.rh
@staticmethod
def test_elapsed_time():
# arrange and act
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
# assert
assert sut.elapsed_time == 0
@staticmethod
def test_start_time():
# arrange and act
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
# assert
assert sut.start_time == ENV_STATE_CTOR_ARG_MINIMAL["start_time"]
@staticmethod
def test_air_density():
# arrange
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
scenario = ppmc.Scenario(gas_data, aero_data, SCENARIO_CTOR_ARG_MINIMAL)
env_state = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
scenario.init_env_state(env_state, 0.0)
# assert
assert 1 * si.kg / si.m**3 < env_state.air_density < 1.5 * si.kg / si.m**3