Exemplo n.º 1
0
def test_rewind(output_dir):
    'test rewind calls base function and clear_output_dir'
    r = Renderer(bna_sample, output_dir)
    bg_name = r.background_map_name
    fg_format = r.foreground_filename_format

    # dump some files into output dir:

    open(os.path.join(output_dir, bg_name), 'w').write('some junk')

    for i in range(5):
        open(os.path.join(output_dir, fg_format.format(i)), 'w'
             ).write('some junk')

    now = datetime.now()
    r.prepare_for_model_run(model_start_time=now)

    assert r._model_start_time == now

    r.rewind()
    assert r._model_start_time is None  # check super is called correctly
    # there should only be a background image now.

    files = os.listdir(output_dir)
    assert files == []
Exemplo n.º 2
0
def test_rewind(output_dir):
    'test rewind calls base function and clear_output_dir'
    r = Renderer(bna_sample, output_dir)
    bg_name = r.background_map_name
    fg_format = r.foreground_filename_format

    # dump some files into output dir:

    open(os.path.join(output_dir, bg_name), 'w').write('some junk')

    for i in range(5):
        open(os.path.join(output_dir, fg_format.format(i)), 'w'
             ).write('some junk')

    now = datetime.now()
    r.prepare_for_model_run(model_start_time=now)

    assert r._model_start_time == now

    r.rewind()
    # check super is called correctly
    assert r._model_start_time is None
    assert r._dt_since_lastoutput is None
    assert r._write_step is True

    # changed renderer and netcdf ouputter to delete old files in
    # prepare_for_model_run() rather than rewind()
    # -- rewind() was getting called a lot
    # -- before there was time to change the ouput file names, etc.
    # So for this unit test, there should only be a background image now.
    files = os.listdir(output_dir)
    assert files == ['background_map.png']
Exemplo n.º 3
0
def test_file_delete(output_dir):
    r = Renderer(bna_sample, output_dir)
    bg_name = r.background_map_name
    fg_format = r.foreground_filename_format

    # dump some files into output dir:

    open(os.path.join(output_dir, bg_name), 'w').write('some junk')

    for i in range(5):
        open(os.path.join(output_dir, fg_format.format(i)), 'w'
             ).write('some junk')

    r.prepare_for_model_run(model_start_time=datetime.now())

    # there should only be a background image now.

    files = os.listdir(output_dir)
    assert files == [r.background_map_name]
Exemplo n.º 4
0
def test_file_delete(output_dir):
    r = Renderer(bna_sample, output_dir)
    bg_name = r.background_map_name
    fg_format = r.foreground_filename_format

    # dump some files into output dir:

    open(os.path.join(output_dir, bg_name), 'w').write('some junk')

    for i in range(5):
        open(os.path.join(output_dir, fg_format.format(i)), 'w'
             ).write('some junk')

    r.prepare_for_model_run(model_start_time=datetime.now())

    # there should only be a background image now.

    files = os.listdir(output_dir)
    assert files == [r.background_map_name]