Exemple #1
0
def test_rerun_with_print():
    del_component_instances(['earth_port'])

    contents = """
name: earth_port
class: EarthPort

print:
- name: earth_surface__temperature
  interval: 20
  format: vtk
    """
    comp = Component.from_string(contents)
    comp.go()

    assert_equal(comp._port.current_time, 100.)
    for i in xrange(5):
        assert_isfile_and_remove('earth_surface__temperature_%04d.vtu' % i)

    del_component_instances(['earth_port'])

    comp = Component.from_string(contents)
    comp.go()

    assert_equal(comp._port.current_time, 100.)
    for i in xrange(5):
        assert_isfile_and_remove('earth_surface__temperature_%04d.vtu' % i)
Exemple #2
0
def test_print_events(tmpdir, with_no_components):
    air_init_string = """
name: air_port
class: AirPort
print:
- name: air__temperature
  interval: 25.
  format: nc
"""
    earth_init_string = """
name: earth_port
class: EarthPort
print:
- name: glacier_top_surface__slope
  interval: 20.
  format: nc
"""
    with tmpdir.as_cwd():
        for _ in range(2):
            del_component_instances(["air_port", "earth_port"])

            air = Component.from_string(air_init_string)
            earth = Component.from_string(earth_init_string)
            earth.connect("air_port", air)
            air.connect("earth_port", earth)
            earth.go()

            assert os.path.isfile("glacier_top_surface__slope.nc")
            assert os.path.isfile("air__temperature.nc")
def test_print_events():
    del_component_instances(['air_port', 'earth_port'])

    air = Component.from_string("""
name: air_port
class: AirPort
print:
- name: air__temperature
  interval: 25.
  format: vtk
""")
    earth = Component.from_string("""
name: earth_port
class: EarthPort
print:
- name: glacier_top_surface__slope
  interval: 20.
  format: vtk
""")
    earth.connect('air_port', air)
    earth.go()

    for i in xrange(5):
        assert_isfile_and_remove('glacier_top_surface__slope_%04d.vtu' % i)
    for i in xrange(4):
        assert_isfile_and_remove('air__temperature_%04d.vtu' % i)
def test_rerun_with_print(tmpdir, with_no_components):
    del_component_instances(["earth_port"])

    contents = """
name: earth_port
class: EarthPort

print:
- name: earth_surface__temperature
  interval: 20
  format: netcdf
    """
    with tmpdir.as_cwd():
        comp = Component.from_string(contents)
        comp.go()

        assert comp._port.current_time == approx(100.0)
        assert os.path.isfile("earth_surface__temperature.nc")
        # os.remove("earth_surface__temperature.nc")

        del_component_instances(["earth_port"])

        comp = Component.from_string(contents)
        comp.go()

        assert comp._port.current_time == approx(100.0)
        assert os.path.isfile("earth_surface__temperature.nc")
Exemple #5
0
def test_print_events():
    del_component_instances(['earth_port'])

    contents = """
name: earth_port
class: EarthPort
print:
- name: earth_surface__temperature
  interval: 0.1
  format: nc
- name: earth_surface__density
  interval: 20.
  format: vtk
- name: glacier_top_surface__slope
  interval: 0.3
  format: nc
    """
    comp = Component.from_string(contents)
    comp.go()

    assert_equal(comp._port.current_time, 100.)
    assert_isfile_and_remove('earth_surface__temperature.nc')
    assert_isfile_and_remove('glacier_top_surface__slope.nc')
    for i in xrange(5):
        assert_isfile_and_remove('earth_surface__density_%04d.vtu' % i)
def test_print_events(tmpdir, with_no_components):
    del_component_instances(["earth_port"])

    contents = """
name: earth_port
class: EarthPort
print:
- name: earth_surface__temperature
  interval: 0.1
  format: nc
- name: earth_surface__density
  interval: 20.
  format: netcdf
- name: glacier_top_surface__slope
  interval: 0.3
  format: nc
    """
    with tmpdir.as_cwd():
        comp = Component.from_string(contents)
        comp.go()

        assert comp._port.current_time == 100.0
        assert os.path.isfile("earth_surface__temperature.nc")
        assert os.path.isfile("glacier_top_surface__slope.nc")
        assert os.path.isfile("earth_surface__density.nc")
Exemple #7
0
def test_from_string():
    del_component_instances(['air_port'])

    contents = """
name: air_port
class: AirPort
    """
    comp = Component.from_string(contents)
    comp.go()
    assert_equal(comp._port.current_time, 100.)
def test_from_string(with_no_components):
    del_component_instances(["air_port"])

    contents = """
name: air_port
class: AirPort
    """
    comp = Component.from_string(contents)
    comp.go()
    assert comp._port.current_time == 100.0