open-space-toolkit-physics 6.0.4__py311-none-manylinux2014_aarch64.whl → 11.3.0__py311-none-manylinux2014_aarch64.whl
Sign up to get free protection for your applications and to get access to all the features.
- {open_space_toolkit_physics-6.0.4.dist-info → open_space_toolkit_physics-11.3.0.dist-info}/METADATA +5 -6
- {open_space_toolkit_physics-6.0.4.dist-info → open_space_toolkit_physics-11.3.0.dist-info}/RECORD +50 -26
- {open_space_toolkit_physics-6.0.4.dist-info → open_space_toolkit_physics-11.3.0.dist-info}/WHEEL +1 -1
- ostk/physics/OpenSpaceToolkitPhysicsPy.cpython-311-aarch64-linux-gnu.so +0 -0
- ostk/physics/__init__.pyi +488 -0
- ostk/physics/coordinate/__init__.pyi +1002 -0
- ostk/physics/coordinate/frame/__init__.pyi +30 -0
- ostk/physics/coordinate/frame/provider/__init__.pyi +77 -0
- ostk/physics/coordinate/frame/provider/iau.pyi +64 -0
- ostk/physics/coordinate/frame/provider/iers.pyi +584 -0
- ostk/physics/coordinate/spherical.pyi +421 -0
- ostk/physics/data/__init__.pyi +459 -0
- ostk/physics/data/provider.pyi +21 -0
- ostk/physics/environment/__init__.pyi +108 -0
- ostk/physics/environment/atmospheric/__init__.pyi +181 -0
- ostk/physics/environment/atmospheric/earth.pyi +552 -0
- ostk/physics/environment/gravitational/__init__.pyi +559 -0
- ostk/physics/environment/gravitational/earth.pyi +56 -0
- ostk/physics/environment/magnetic/__init__.pyi +171 -0
- ostk/physics/environment/magnetic/earth.pyi +56 -0
- ostk/physics/environment/object/__init__.pyi +430 -0
- ostk/physics/environment/object/celestial/__init__.pyi +248 -0
- ostk/physics/environment/object/celestial/moon.pyi +2 -0
- ostk/physics/environment/object/celestial/sun.pyi +2 -0
- ostk/physics/libopen-space-toolkit-physics.so.11 +0 -0
- ostk/physics/py.typed +0 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_manager.py +0 -11
- ostk/physics/test/coordinate/spherical/test_lla.py +56 -4
- ostk/physics/test/coordinate/test_position.py +129 -134
- ostk/physics/test/data/conftest.py +3 -1
- ostk/physics/test/data/provider/test_provider.py +34 -0
- ostk/physics/test/data/test_manifest.py +4 -1
- ostk/physics/test/data/test_manifest_manager.py +6 -8
- ostk/physics/test/data/test_scalar.py +2 -2
- ostk/physics/test/data/test_vector.py +2 -2
- ostk/physics/test/environment/atmospheric/earth/test_manager.py +0 -14
- ostk/physics/test/environment/gravitational/earth/test_manager.py +0 -25
- ostk/physics/test/environment/gravitational/test_earth.py +8 -0
- ostk/physics/test/environment/magnetic/earth/test_manager.py +0 -20
- ostk/physics/test/test_environment.py +58 -40
- ostk/physics/test/time/test_duration.py +0 -7
- ostk/physics/test/time/test_instant.py +16 -0
- ostk/physics/test/time/test_interval.py +177 -10
- ostk/physics/test/time/test_time.py +80 -136
- ostk/physics/test/unit/derived/test_angle.py +1 -1
- ostk/physics/test/unit/test_derived.py +36 -0
- ostk/physics/time.pyi +1744 -0
- ostk/physics/unit.pyi +1590 -0
- ostk/physics/libopen-space-toolkit-physics.so.6 +0 -0
- {open_space_toolkit_physics-6.0.4.dist-info → open_space_toolkit_physics-11.3.0.dist-info}/top_level.txt +0 -0
- {open_space_toolkit_physics-6.0.4.dist-info → open_space_toolkit_physics-11.3.0.dist-info}/zip-safe +0 -0
@@ -12,68 +12,86 @@ def environment() -> Environment:
|
|
12
12
|
return Environment.default()
|
13
13
|
|
14
14
|
|
15
|
-
|
16
|
-
instant = Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC)
|
17
|
-
objects = []
|
15
|
+
class TestEnvironment:
|
18
16
|
|
19
|
-
|
17
|
+
def test_constructors(self):
|
18
|
+
instant = Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC)
|
19
|
+
objects = []
|
20
20
|
|
21
|
-
|
22
|
-
assert isinstance(env, Environment)
|
21
|
+
env: Environment = Environment(instant, objects)
|
23
22
|
|
23
|
+
assert env is not None
|
24
|
+
assert isinstance(env, Environment)
|
24
25
|
|
25
|
-
|
26
|
-
assert Environment.undefined() is not None
|
27
|
-
assert Environment.undefined().is_defined() is False
|
26
|
+
env = Environment(instant, objects, set_global_instance=True)
|
28
27
|
|
28
|
+
assert env is not None
|
29
|
+
assert isinstance(env, Environment)
|
29
30
|
|
30
|
-
def
|
31
|
-
|
31
|
+
def test_undefined(self):
|
32
|
+
assert Environment.undefined() is not None
|
33
|
+
assert Environment.undefined().is_defined() is False
|
32
34
|
|
35
|
+
def test_default(self):
|
36
|
+
assert Environment.default() is not None
|
37
|
+
assert Environment.default(set_global_instance=True) is not None
|
33
38
|
|
34
|
-
def
|
35
|
-
|
39
|
+
def test_is_defined(self, environment: Environment):
|
40
|
+
assert environment.is_defined() is not None
|
36
41
|
|
42
|
+
def test_has_object_with_name(self, environment: Environment):
|
43
|
+
assert environment.has_object_with_name("Earth") is not None
|
37
44
|
|
38
|
-
|
39
|
-
|
45
|
+
@pytest.mark.skip
|
46
|
+
def test_intersects(self, environment: Environment):
|
47
|
+
assert environment.intersects() is not None
|
40
48
|
|
49
|
+
def test_access_objects(self, environment: Environment):
|
50
|
+
assert environment.access_objects() is not None
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
assert environment.intersects() is not None
|
52
|
+
def test_access_object_with_name(self, environment: Environment):
|
53
|
+
assert environment.access_object_with_name("Earth") is not None
|
45
54
|
|
55
|
+
def test_access_celestial_object_with_name(self, environment: Environment):
|
56
|
+
assert environment.access_celestial_object_with_name("Earth") is not None
|
46
57
|
|
47
|
-
def
|
48
|
-
|
58
|
+
def test_get_instant(self, environment: Environment):
|
59
|
+
assert environment.get_instant() is not None
|
49
60
|
|
61
|
+
def test_get_object_names(self, environment: Environment):
|
62
|
+
assert environment.get_object_names() is not None
|
50
63
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def test_environment_access_celestial_object_with_name(environment: Environment):
|
56
|
-
assert environment.access_celestial_object_with_name("Earth") is not None
|
64
|
+
def test_set_instant(self, environment: Environment):
|
65
|
+
environment.set_instant(
|
66
|
+
Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC)
|
67
|
+
)
|
57
68
|
|
69
|
+
def test_is_position_in_eclipse(self, environment: Environment):
|
70
|
+
environment.set_instant(
|
71
|
+
Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0), Scale.UTC)
|
72
|
+
)
|
58
73
|
|
59
|
-
|
60
|
-
|
74
|
+
assert environment.is_position_in_eclipse(
|
75
|
+
Position.meters(
|
76
|
+
[7000e3, 0.0, 0.0],
|
77
|
+
Frame.ITRF(),
|
78
|
+
)
|
79
|
+
)
|
61
80
|
|
81
|
+
def test_access_global_instance(self):
|
82
|
+
with pytest.raises(RuntimeError):
|
83
|
+
Environment.access_global_instance()
|
62
84
|
|
63
|
-
|
64
|
-
assert environment.get_object_names() is not None
|
85
|
+
Environment.default(set_global_instance=True)
|
65
86
|
|
87
|
+
assert Environment.access_global_instance() is not None
|
66
88
|
|
67
|
-
def
|
68
|
-
|
89
|
+
def test_has_global_instance(self):
|
90
|
+
assert Environment.has_global_instance() is False
|
69
91
|
|
92
|
+
Environment.default(set_global_instance=True)
|
70
93
|
|
71
|
-
|
72
|
-
environment.set_instant(Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0), Scale.UTC))
|
94
|
+
assert Environment.has_global_instance() is True
|
73
95
|
|
74
|
-
|
75
|
-
|
76
|
-
[7000e3, 0.0, 0.0],
|
77
|
-
Frame.ITRF(),
|
78
|
-
)
|
79
|
-
)
|
96
|
+
def teardown_method(self, method):
|
97
|
+
Environment.reset_global_instance()
|
@@ -10,13 +10,6 @@ from ostk.physics.time import Duration
|
|
10
10
|
|
11
11
|
|
12
12
|
class TestDuration:
|
13
|
-
def test_constructor_success_int(self):
|
14
|
-
assert Duration(0).in_seconds() == 0.0
|
15
|
-
assert Duration(int(-1e9)).in_seconds() == -1.0
|
16
|
-
assert Duration(int(+1e9)).in_seconds() == +1.0
|
17
|
-
assert Duration(-1e9).in_seconds() == -1.0
|
18
|
-
assert Duration(+1e9).in_seconds() == +1.0
|
19
|
-
|
20
13
|
def test_constructor_success_timedelta(self):
|
21
14
|
assert Duration(timedelta(days=123)).in_days() == 123.0
|
22
15
|
assert Duration(timedelta(hours=123)).in_hours() == 123.0
|
@@ -21,6 +21,10 @@ def test_instant_J2000():
|
|
21
21
|
assert Instant.J2000() is not None
|
22
22
|
|
23
23
|
|
24
|
+
def test_instant_GPS_epock():
|
25
|
+
assert Instant.GPS_epoch() is not None
|
26
|
+
|
27
|
+
|
24
28
|
def test_instant_datetime():
|
25
29
|
assert (
|
26
30
|
Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0), Scale.UTC) is not None
|
@@ -37,6 +41,18 @@ def test_instant_modified_julian_date():
|
|
37
41
|
assert Instant.modified_julian_date(58119.0, Scale.UTC) is not None
|
38
42
|
|
39
43
|
|
44
|
+
def test_instant_parse():
|
45
|
+
assert Instant.parse("2024-01-01 00:01:02.000", Scale.UTC) is not None
|
46
|
+
assert (
|
47
|
+
Instant.parse("2024-01-01 00:01:02.000", Scale.UTC, DateTime.Format.Standard)
|
48
|
+
is not None
|
49
|
+
)
|
50
|
+
assert (
|
51
|
+
Instant.parse("2024-01-01T00:01:02.000", Scale.UTC, DateTime.Format.ISO8601)
|
52
|
+
is not None
|
53
|
+
)
|
54
|
+
|
55
|
+
|
40
56
|
def test_instant_operators():
|
41
57
|
instant = Instant.J2000()
|
42
58
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
|
5
|
+
from datetime import datetime
|
6
|
+
|
5
7
|
from ostk.core.type import String
|
6
8
|
|
7
9
|
from ostk.physics.time import Scale
|
@@ -90,6 +92,16 @@ def instant_3() -> Interval:
|
|
90
92
|
return Instant.J2000() + Duration.minutes(3.0)
|
91
93
|
|
92
94
|
|
95
|
+
def build_interval(
|
96
|
+
offset_1: float, offset_2: float, type: Interval.Type = Interval.Type.Closed
|
97
|
+
) -> Interval:
|
98
|
+
return Interval(
|
99
|
+
Instant.J2000() + Duration.seconds(offset_1),
|
100
|
+
Instant.J2000() + Duration.seconds(offset_2),
|
101
|
+
type,
|
102
|
+
)
|
103
|
+
|
104
|
+
|
93
105
|
class TestInterval:
|
94
106
|
def test_interval_constructor(self):
|
95
107
|
interval: Interval = Interval(
|
@@ -111,6 +123,15 @@ class TestInterval:
|
|
111
123
|
assert isinstance(Interval.undefined(), Interval)
|
112
124
|
|
113
125
|
def test_interval_constructor_closed(self):
|
126
|
+
assert (
|
127
|
+
Interval(
|
128
|
+
Instant.J2000(),
|
129
|
+
Instant.J2000() + Duration.minutes(1.0),
|
130
|
+
Interval.Type.Closed,
|
131
|
+
)
|
132
|
+
is not None
|
133
|
+
)
|
134
|
+
|
114
135
|
assert (
|
115
136
|
Interval.closed(Instant.J2000(), Instant.J2000() + Duration.minutes(1.0))
|
116
137
|
is not None
|
@@ -126,6 +147,11 @@ class TestInterval:
|
|
126
147
|
is not None
|
127
148
|
)
|
128
149
|
|
150
|
+
assert (
|
151
|
+
Interval.open(Instant.J2000(), Instant.J2000() + Duration.minutes(1.0))
|
152
|
+
is not None
|
153
|
+
)
|
154
|
+
|
129
155
|
def test_interval_constructor_half_open_left(self):
|
130
156
|
assert (
|
131
157
|
Interval(
|
@@ -136,6 +162,13 @@ class TestInterval:
|
|
136
162
|
is not None
|
137
163
|
)
|
138
164
|
|
165
|
+
assert (
|
166
|
+
Interval.half_open_left(
|
167
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0)
|
168
|
+
)
|
169
|
+
is not None
|
170
|
+
)
|
171
|
+
|
139
172
|
def test_interval_constructor_half_open_right(self):
|
140
173
|
assert (
|
141
174
|
Interval(
|
@@ -146,6 +179,13 @@ class TestInterval:
|
|
146
179
|
is not None
|
147
180
|
)
|
148
181
|
|
182
|
+
assert (
|
183
|
+
Interval.half_open_right(
|
184
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0)
|
185
|
+
)
|
186
|
+
is not None
|
187
|
+
)
|
188
|
+
|
149
189
|
def test_interval_constructor_centered(self):
|
150
190
|
assert (
|
151
191
|
Interval.centered(
|
@@ -180,19 +220,15 @@ class TestInterval:
|
|
180
220
|
assert interval.is_defined()
|
181
221
|
assert Interval.undefined().is_defined() is False
|
182
222
|
|
183
|
-
def test_interval_is_degenerate(self, interval: Interval):
|
184
|
-
assert interval.is_degenerate() is False
|
185
|
-
assert Interval(Instant.J2000(), Instant.J2000()).is_degenerate()
|
186
|
-
|
187
223
|
def test_interval_is_degenerate(self, interval: Interval):
|
188
224
|
assert interval.is_degenerate() is False
|
189
225
|
assert Interval.closed(Instant.J2000(), Instant.J2000()).is_degenerate()
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
226
|
+
|
227
|
+
with pytest.raises(Exception):
|
228
|
+
Interval(Instant.J2000(), Instant.J2000(), Interval.Type.Open).is_degenerate()
|
229
|
+
Interval.centered(
|
230
|
+
Instant.J2000(), Duration.minutes(0.0), Interval.Type.Open
|
231
|
+
).is_degenerate()
|
196
232
|
|
197
233
|
def test_interval_intersects(
|
198
234
|
self,
|
@@ -263,3 +299,134 @@ class TestInterval:
|
|
263
299
|
assert isinstance(grid, list)
|
264
300
|
assert isinstance(grid[0], Instant)
|
265
301
|
assert len(grid) == 61
|
302
|
+
|
303
|
+
def test_to_datetime_span(self, interval: Interval):
|
304
|
+
assert interval.to_datetime_span() is not None
|
305
|
+
assert isinstance(interval.to_datetime_span(), tuple)
|
306
|
+
assert isinstance(interval.to_datetime_span()[0], datetime)
|
307
|
+
assert isinstance(interval.to_datetime_span()[1], datetime)
|
308
|
+
|
309
|
+
def test_get_intersection_with(self):
|
310
|
+
intersection: Interval = build_interval(0.0, 10.0).get_intersection_with(
|
311
|
+
build_interval(5.0, 15.0)
|
312
|
+
)
|
313
|
+
assert isinstance(intersection, Interval)
|
314
|
+
assert intersection.is_defined()
|
315
|
+
|
316
|
+
intersection: Interval = build_interval(0.0, 10.0).get_intersection_with(
|
317
|
+
build_interval(20.0, 30.0)
|
318
|
+
)
|
319
|
+
assert isinstance(intersection, Interval)
|
320
|
+
assert not intersection.is_defined()
|
321
|
+
|
322
|
+
def test_get_union_with(self):
|
323
|
+
union: Interval = build_interval(0.0, 10.0).get_union_with(
|
324
|
+
build_interval(5.0, 15.0)
|
325
|
+
)
|
326
|
+
assert isinstance(union, Interval)
|
327
|
+
assert union.is_defined()
|
328
|
+
|
329
|
+
union: Interval = build_interval(0.0, 10.0).get_union_with(
|
330
|
+
build_interval(20.0, 30.0)
|
331
|
+
)
|
332
|
+
assert isinstance(union, Interval)
|
333
|
+
assert not union.is_defined()
|
334
|
+
|
335
|
+
def test_clip(self):
|
336
|
+
intervals: list[Interval] = [
|
337
|
+
build_interval(0.0, 10.0),
|
338
|
+
build_interval(20.0, 30.0),
|
339
|
+
]
|
340
|
+
|
341
|
+
expected: list[Interval] = [
|
342
|
+
build_interval(5.0, 10.0),
|
343
|
+
build_interval(20.0, 25.0),
|
344
|
+
]
|
345
|
+
|
346
|
+
assert Interval.clip(intervals, build_interval(5.0, 25.0)) == expected
|
347
|
+
|
348
|
+
def test_sort(self):
|
349
|
+
intervals: list[Interval] = [
|
350
|
+
build_interval(20.0, 30.0),
|
351
|
+
build_interval(0.0, 10.0),
|
352
|
+
]
|
353
|
+
|
354
|
+
expected: list[Interval] = [
|
355
|
+
build_interval(0.0, 10.0),
|
356
|
+
build_interval(20.0, 30.0),
|
357
|
+
]
|
358
|
+
|
359
|
+
assert Interval.sort(intervals) == expected
|
360
|
+
|
361
|
+
def test_merge(self):
|
362
|
+
intervals: list[Interval] = [
|
363
|
+
build_interval(20.0, 30.0),
|
364
|
+
build_interval(5.0, 15.0),
|
365
|
+
build_interval(0.0, 10.0),
|
366
|
+
]
|
367
|
+
|
368
|
+
expected: list[Interval] = [
|
369
|
+
build_interval(0.0, 15.0),
|
370
|
+
build_interval(20.0, 30.0),
|
371
|
+
]
|
372
|
+
|
373
|
+
assert Interval.merge(intervals) == expected
|
374
|
+
|
375
|
+
def test_get_gaps(self):
|
376
|
+
intervals: list[Interval] = [
|
377
|
+
build_interval(5.0, 10.0),
|
378
|
+
build_interval(20.0, 30.0),
|
379
|
+
]
|
380
|
+
|
381
|
+
expected: list[Interval] = [
|
382
|
+
build_interval(10.0, 20.0, Interval.Type.Open),
|
383
|
+
]
|
384
|
+
|
385
|
+
assert Interval.get_gaps(intervals) == expected
|
386
|
+
|
387
|
+
expected = [
|
388
|
+
build_interval(0.0, 5.0, Interval.Type.Open),
|
389
|
+
build_interval(10.0, 20.0, Interval.Type.Open),
|
390
|
+
build_interval(30.0, 35.0, Interval.Type.Open),
|
391
|
+
]
|
392
|
+
|
393
|
+
assert (
|
394
|
+
Interval.get_gaps(intervals, build_interval(0.0, 35.0, Interval.Type.Open))
|
395
|
+
== expected
|
396
|
+
)
|
397
|
+
|
398
|
+
def test_logical_or(self):
|
399
|
+
intervals_1: list[Interval] = [
|
400
|
+
build_interval(0.0, 10.0),
|
401
|
+
build_interval(20.0, 30.0),
|
402
|
+
]
|
403
|
+
|
404
|
+
intervals_2: list[Interval] = [
|
405
|
+
build_interval(5.0, 25.0),
|
406
|
+
build_interval(40.0, 50.0),
|
407
|
+
]
|
408
|
+
|
409
|
+
expected: list[Interval] = [
|
410
|
+
build_interval(0.0, 30.0),
|
411
|
+
build_interval(40.0, 50.0),
|
412
|
+
]
|
413
|
+
|
414
|
+
assert Interval.logical_or(intervals_1, intervals_2) == expected
|
415
|
+
|
416
|
+
def test_logical_and(self):
|
417
|
+
intervals_1: list[Interval] = [
|
418
|
+
build_interval(0.0, 10.0),
|
419
|
+
build_interval(20.0, 30.0),
|
420
|
+
]
|
421
|
+
|
422
|
+
intervals_2: list[Interval] = [
|
423
|
+
build_interval(5.0, 25.0),
|
424
|
+
build_interval(40.0, 50.0),
|
425
|
+
]
|
426
|
+
|
427
|
+
expected: list[Interval] = [
|
428
|
+
build_interval(5.0, 10.0),
|
429
|
+
build_interval(20.0, 25.0),
|
430
|
+
]
|
431
|
+
|
432
|
+
assert Interval.logical_and(intervals_1, intervals_2) == expected
|
@@ -1,170 +1,114 @@
|
|
1
1
|
# Apache License 2.0
|
2
2
|
|
3
3
|
import pytest
|
4
|
-
|
5
4
|
from ostk.core.type import String
|
6
|
-
|
7
5
|
from ostk.physics.time import Time
|
8
6
|
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def test_time_undefined():
|
15
|
-
assert Time.undefined() is not None
|
16
|
-
|
17
|
-
|
18
|
-
def test_time_midnight():
|
19
|
-
assert Time.midnight() is not None
|
20
|
-
|
21
|
-
|
22
|
-
def test_time_noon():
|
23
|
-
assert Time.noon() is not None
|
24
|
-
|
25
|
-
|
26
|
-
def test_time_parse():
|
27
|
-
## Using python strings
|
28
|
-
|
29
|
-
# Testing with default format argument (Time::Format::Undefined)
|
30
|
-
time: Time = Time.parse("00:00:00")
|
31
|
-
|
32
|
-
assert time is not None
|
33
|
-
assert isinstance(time, Time)
|
34
|
-
assert time.is_defined()
|
35
|
-
|
36
|
-
# Testing with Time.Format.Standard
|
37
|
-
time: Time = Time.parse("00:00:00", Time.Format.Standard)
|
38
|
-
|
39
|
-
assert time is not None
|
40
|
-
assert isinstance(time, Time)
|
41
|
-
assert time.is_defined()
|
42
|
-
|
43
|
-
# Testing with Time.Format.ISO8601
|
44
|
-
time: Time = Time.parse("00:00:00", Time.Format.ISO8601)
|
45
|
-
|
46
|
-
assert time is not None
|
47
|
-
assert isinstance(time, Time)
|
48
|
-
assert time.is_defined()
|
49
|
-
|
50
|
-
## Using String class
|
51
|
-
|
52
|
-
# Testing with default format argument (Time::Format::Undefined)
|
53
|
-
time: Time = Time.parse(String("00:00:00"))
|
54
|
-
|
55
|
-
assert time is not None
|
56
|
-
assert isinstance(time, Time)
|
57
|
-
assert time.is_defined()
|
58
|
-
|
59
|
-
# Testing with Time.Format.Standard
|
60
|
-
time: Time = Time.parse(String("00:00:00"), Time.Format.Standard)
|
61
|
-
|
62
|
-
assert time is not None
|
63
|
-
assert isinstance(time, Time)
|
64
|
-
assert time.is_defined()
|
65
|
-
|
66
|
-
# Testing with Time.Format.ISO8601
|
67
|
-
time: Time = Time.parse(String("00:00:00"), Time.Format.ISO8601)
|
68
|
-
|
69
|
-
assert time is not None
|
70
|
-
assert isinstance(time, Time)
|
71
|
-
assert time.is_defined()
|
72
|
-
|
73
|
-
|
74
|
-
def test_time_operators():
|
75
|
-
time = Time(0, 0, 0)
|
76
|
-
|
77
|
-
assert (time == time) is not None
|
78
|
-
assert (time != time) is not None
|
79
|
-
|
80
|
-
|
81
|
-
def test_time_is_defined():
|
82
|
-
time = Time(0, 0, 0)
|
83
|
-
|
84
|
-
assert time.is_defined() is not None
|
85
|
-
|
86
|
-
|
87
|
-
def test_time_get_hour():
|
88
|
-
time = Time(0, 0, 0)
|
89
|
-
|
90
|
-
assert time.get_hour() is not None
|
91
|
-
|
92
|
-
|
93
|
-
def test_time_get_minute():
|
94
|
-
time = Time(0, 0, 0)
|
95
|
-
|
96
|
-
assert time.get_minute() is not None
|
97
|
-
|
98
|
-
|
99
|
-
def test_time_get_second():
|
100
|
-
time = Time(0, 0, 0)
|
101
|
-
|
102
|
-
assert time.get_second() is not None
|
103
|
-
|
104
|
-
|
105
|
-
def test_time_get_millisecond():
|
106
|
-
time = Time(0, 0, 0)
|
107
|
-
|
108
|
-
assert time.get_millisecond() is not None
|
109
|
-
|
110
|
-
|
111
|
-
def test_time_get_microsecond():
|
112
|
-
time = Time(0, 0, 0)
|
113
|
-
|
114
|
-
assert time.get_microsecond() is not None
|
8
|
+
@pytest.fixture
|
9
|
+
def time() -> Time:
|
10
|
+
return Time(0, 0, 0)
|
115
11
|
|
116
12
|
|
117
|
-
|
118
|
-
|
13
|
+
class TestTime:
|
14
|
+
def test_constructors(self, time: Time) -> None:
|
15
|
+
assert time is not None
|
119
16
|
|
120
|
-
|
17
|
+
@pytest.mark.parametrize(
|
18
|
+
"time_string, format",
|
19
|
+
[
|
20
|
+
("00:00:00", None),
|
21
|
+
("00:00:00", Time.Format.Standard),
|
22
|
+
("00:00:00", Time.Format.ISO8601),
|
23
|
+
(String("00:00:00"), None),
|
24
|
+
(String("00:00:00"), Time.Format.Standard),
|
25
|
+
(String("00:00:00"), Time.Format.ISO8601),
|
26
|
+
],
|
27
|
+
)
|
28
|
+
def test_parse(self, time_string, format) -> None:
|
29
|
+
if format is None:
|
30
|
+
time = Time.parse(time_string)
|
31
|
+
else:
|
32
|
+
time = Time.parse(time_string, format)
|
121
33
|
|
34
|
+
assert time is not None
|
35
|
+
assert isinstance(time, Time)
|
36
|
+
assert time.is_defined()
|
122
37
|
|
123
|
-
def
|
124
|
-
|
38
|
+
def test_operators(self, time: Time) -> None:
|
39
|
+
assert (time == time) is not None
|
40
|
+
assert (time != time) is not None
|
125
41
|
|
126
|
-
|
42
|
+
def test_is_defined(self, time: Time) -> None:
|
43
|
+
assert time.is_defined() is not None
|
127
44
|
|
45
|
+
def test_get_hour(self, time: Time) -> None:
|
46
|
+
assert time.get_hour() is not None
|
128
47
|
|
129
|
-
def
|
130
|
-
|
48
|
+
def test_get_minute(self, time: Time) -> None:
|
49
|
+
assert time.get_minute() is not None
|
131
50
|
|
132
|
-
|
133
|
-
|
134
|
-
assert time.to_string(Time.Format.ISO8601) is not None
|
51
|
+
def test_get_second(self, time: Time) -> None:
|
52
|
+
assert time.get_second() is not None
|
135
53
|
|
54
|
+
def test_get_millisecond(self, time: Time) -> None:
|
55
|
+
assert time.get_millisecond() is not None
|
136
56
|
|
137
|
-
def
|
138
|
-
|
57
|
+
def test_get_microsecond(self, time: Time) -> None:
|
58
|
+
assert time.get_microsecond() is not None
|
139
59
|
|
140
|
-
time
|
60
|
+
def test_get_nanosecond(self, time: Time) -> None:
|
61
|
+
assert time.get_nanosecond() is not None
|
141
62
|
|
63
|
+
def test_get_floating_seconds(self, time: Time) -> None:
|
64
|
+
assert time.get_floating_seconds() is not None
|
142
65
|
|
143
|
-
def
|
144
|
-
|
66
|
+
def test_get_total_floating_seconds(self, time: Time) -> None:
|
67
|
+
assert time.get_total_floating_seconds() is not None
|
145
68
|
|
146
|
-
time
|
69
|
+
def test_get_total_floating_hours(self, time: Time) -> None:
|
70
|
+
assert time.get_total_floating_hours() is not None
|
147
71
|
|
72
|
+
def test_to_string(self, time: Time) -> None:
|
73
|
+
assert time.to_string() is not None
|
74
|
+
assert time.to_string(Time.Format.Standard) is not None
|
75
|
+
assert time.to_string(Time.Format.ISO8601) is not None
|
148
76
|
|
149
|
-
def
|
150
|
-
|
77
|
+
def test_set_hour(self, time: Time) -> None:
|
78
|
+
time.set_hour(1)
|
79
|
+
assert time.get_hour() == 1
|
151
80
|
|
152
|
-
time
|
81
|
+
def test_set_minute(self, time: Time) -> None:
|
82
|
+
time.set_minute(1)
|
83
|
+
assert time.get_minute() == 1
|
153
84
|
|
85
|
+
def test_set_second(self, time: Time) -> None:
|
86
|
+
time.set_second(1)
|
87
|
+
assert time.get_second() == 1
|
154
88
|
|
155
|
-
def
|
156
|
-
|
89
|
+
def test_set_millisecond(self, time: Time) -> None:
|
90
|
+
time.set_millisecond(1)
|
91
|
+
assert time.get_millisecond() == 1
|
157
92
|
|
158
|
-
time
|
93
|
+
def test_set_microsecond(self, time: Time) -> None:
|
94
|
+
time.set_microsecond(1)
|
95
|
+
assert time.get_microsecond() == 1
|
159
96
|
|
97
|
+
def test_set_nanosecond(self, time: Time) -> None:
|
98
|
+
time.set_nanosecond(1)
|
99
|
+
assert time.get_nanosecond() == 1
|
160
100
|
|
161
|
-
def
|
162
|
-
|
101
|
+
def test_undefined(self) -> None:
|
102
|
+
assert Time.undefined() is not None
|
163
103
|
|
164
|
-
|
104
|
+
def test_midnight(self) -> None:
|
105
|
+
assert Time.midnight() is not None
|
165
106
|
|
107
|
+
def test_noon(self) -> None:
|
108
|
+
assert Time.noon() is not None
|
166
109
|
|
167
|
-
def
|
168
|
-
|
110
|
+
def test_hours(self) -> None:
|
111
|
+
assert Time.hours(12.0345) is not None
|
169
112
|
|
170
|
-
|
113
|
+
def test_seconds(self) -> None:
|
114
|
+
assert Time.seconds(1238.0345) is not None
|