Skip to content

Commit 4131ec7

Browse files
added a test of component mover running backwards -- now failing
1 parent 3d0bcde commit 4131ec7

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

py_gnome/tests/unit_tests/test_cy/test_cy_component_mover.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
4-
51
import os
62

73
import numpy as np
@@ -14,6 +10,7 @@
1410

1511
from ..conftest import testdata
1612

13+
import pytest
1714

1815
class ComponentMove(cy_fixtures.CyTestMove):
1916

@@ -104,6 +101,7 @@ def test_certain_move():
104101
print('--------------')
105102
print('test_certain_move')
106103
tgt = ComponentMove()
104+
107105
tgt.certain_move()
108106

109107
assert np.all(tgt.delta['lat'] != 0)
@@ -174,5 +172,45 @@ def test_ref_point():
174172
assert c_component.ref_point == tuple(tgt)
175173

176174

175+
@pytest.mark.xfail(reason="component mover can't take negative integer")
176+
def test_run_backwards():
177+
"""
178+
test that a component mover can work running backwards.
179+
"""
180+
tgt = ComponentMove()
181+
182+
# same as the regular one, except with negative timestep.
183+
tgt.component.get_move(
184+
tgt.model_time,
185+
- tgt.time_step,
186+
tgt.ref,
187+
tgt.delta,
188+
tgt.status,
189+
basic_types.spill_type.forecast,
190+
)
191+
deltas = tgt.delta
192+
tgt.component.model_step_is_done()
193+
194+
print(deltas)
195+
196+
# deltas when running forward:
197+
# [(4.42500067e-06, 9.92425248e-07, 0.)
198+
# (4.42500067e-06, 9.92425248e-07, 0.)
199+
# (4.42500067e-06, 9.92425248e-07, 0.)
200+
# (4.42500067e-06, 9.92425248e-07, 0.)]
201+
202+
# Not sure how to test that it's correct, but maybe:
203+
# deltas should be all the same:
204+
for d in deltas:
205+
assert d == deltas[0]
206+
207+
# They should be negative (frontwards are positive)
208+
assert deltas['lat'][0] < 0.0
209+
assert deltas['long'][0] < 0.0
210+
assert deltas['z'][0] == 0.0
211+
212+
assert False
213+
214+
177215
if __name__ == '__main__':
178216
test_move()

0 commit comments

Comments
 (0)