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)
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_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_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")
def test_print_events(tmpdir, with_no_components): air = Component.load(""" name: air_port class: AirPort print: - name: air__temperature interval: 25. format: nc """) earth = Component.load(""" name: earth_port class: EarthPort print: - name: glacier_top_surface__slope interval: 20. format: netcdf """) with tmpdir.as_cwd(): earth.connect( "air_port", air, vars_to_map=[ ("glacier_top_surface__slope", "air__temperature"), ("earth_surface__temperature", "air__temperature"), ], ) earth.go() assert os.path.isfile("glacier_top_surface__slope.nc") assert os.path.isfile("air__temperature.nc")
def test_print_events(tmpdir, with_no_components): air = Component.load( """ name: air_port class: AirPort print: - name: air__temperature interval: 25. format: nc """ ) earth = Component.load( """ name: earth_port class: EarthPort print: - name: glacier_top_surface__slope interval: 20. format: netcdf """ ) with tmpdir.as_cwd(): earth.connect( "air_port", air, vars_to_map=[ ("glacier_top_surface__slope", "air__temperature"), ("earth_surface__temperature", "air__temperature"), ], ) earth.go() assert os.path.isfile("glacier_top_surface__slope.nc") assert os.path.isfile("air__temperature.nc")
def test_print_events(): air = Component.load(""" name: air_port class: AirPort print: - name: air__temperature interval: 25. format: vtk """) earth = Component.load(""" name: earth_port class: EarthPort print: - name: glacier_top_surface__slope interval: 20. format: vtk """) earth.connect('air_port', air, vars_to_map=[ ( 'glacier_top_surface__slope', 'air__temperature', ), ( 'earth_surface__temperature', 'air__temperature', ), ]) 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_no_events(): del_component_instances(['air_port', 'earth_port']) air = Component('AirPort', name='air_port', uses=[], provides=[], events=[]) earth = Component('EarthPort', name='earth_port', uses=['air_port', ], provides=[], events=[]) earth.connect('air_port', air) air.connect('earth_port', earth) earth.go() assert_equal(air._port.current_time, 100.) assert_equal(earth._port.current_time, 100.)
def test_no_events(with_no_components): del_component_instances(["air_port", "earth_port"]) air = Component("AirPort", name="air_port", uses=[], provides=[], events=[]) earth = Component( "EarthPort", name="earth_port", uses=["air_port"], provides=[], events=[] ) earth.connect("air_port", air) earth.go() assert earth._port.current_time == 100.0 assert air._port.current_time == 100.0
def test_no_events(with_no_components): del_component_instances(["air_port", "earth_port"]) air = Component("AirPort", name="air_port", uses=[], provides=[], events=[]) earth = Component( "EarthPort", name="earth_port", uses=["air_port"], provides=[], events=[] ) earth.connect("air_port", air) air.connect("earth_port", earth) earth.go() assert air._port.current_time == 100.0 assert earth._port.current_time == 100.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")
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
def test_rerun(): del_component_instances(['AirPort']) comp = Component('AirPort', uses=[], provides=[], events=[]) comp.go() assert_equal(comp._port.current_time, 100.) comp.go() assert_equal(comp._port.current_time, 100.)
def test_rerun(with_no_components): del_component_instances(["AirPort"]) comp = Component("AirPort", uses=[], provides=[], events=[]) comp.go() assert comp._port.current_time == 100.0 comp.go() assert comp._port.current_time == 100.0