-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathpyAtmosphere_TEST.py
62 lines (44 loc) · 2.16 KB
/
pyAtmosphere_TEST.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
# Copyright (C) 2022 Open Source Robotics Foundation
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from gz.math7 import Pose3d, Temperature
from sdformat import Atmosphere
import sdformat as sdf
import unittest
class AtmosphereTEST(unittest.TestCase):
def test_default_construction(self):
atmosphere = Atmosphere()
self.assertEqual(sdf.AtmosphereType.ADIABATIC, atmosphere.type())
self.assertAlmostEqual(288.15, atmosphere.temperature().kelvin())
self.assertAlmostEqual(-0.0065, atmosphere.temperature_gradient())
self.assertAlmostEqual(101325, atmosphere.pressure())
def test_set(self):
atmosphere = Atmosphere()
atmosphere.set_type(sdf.AtmosphereType.ADIABATIC)
self.assertEqual(sdf.AtmosphereType.ADIABATIC, atmosphere.type())
atmosphere.set_temperature(Temperature(123.23))
self.assertAlmostEqual(123.23, atmosphere.temperature().kelvin())
atmosphere.set_temperature_gradient(-1.65)
self.assertAlmostEqual(-1.65, atmosphere.temperature_gradient())
atmosphere.set_pressure(76531.3)
self.assertAlmostEqual(76531.3, atmosphere.pressure())
def test_copy_assignment(self):
atmosphere = Atmosphere()
atmosphere.set_temperature(Temperature(123.23))
atmosphere.set_temperature_gradient(-1.65)
atmosphere.set_pressure(76531.3)
atmosphere2 = atmosphere
self.assertEqual(sdf.AtmosphereType.ADIABATIC, atmosphere2.type())
self.assertAlmostEqual(123.23, atmosphere2.temperature().kelvin())
self.assertAlmostEqual(-1.65, atmosphere2.temperature_gradient())
self.assertAlmostEqual(76531.3, atmosphere2.pressure())
self.assertEqual(atmosphere, atmosphere2)
if __name__ == '__main__':
unittest.main()