Esempio n. 1
0
def test_update_autoroute_input_file_invalid():
    """
    Checks AutoRoute input file update with invalid input
    """
    main_tests_folder = os.path.dirname(os.path.abspath(__file__))
    
    original_data_path = os.path.join(main_tests_folder, 'original')
    output_data_path = os.path.join(main_tests_folder, 'output')

    print "TEST 3: UPDATE INPUT FILE WITH FAKE INPUTS"
    auto_mng_fake = AutoRoute("autoroute_exe_path_dummy",
                             stream_file=os.path.join(original_data_path, "streamflow_raster.tif"),
                             dem_file=os.path.join(output_data_path, "elevation.tif"),
                             out_flood_map_shapefile_path="right_here.shp",
                             )

    original_fake_input_file = os.path.join(output_data_path, 
                                            "AUTOROUTE_INPUT_FILE-INVALID_INPUTS.txt")
    out_fake_input_file = os.path.join(output_data_path, 
                                       "AUTOROUTE_INPUT_FILE-INVALID_INPUTS.txt")
    copy(original_fake_input_file, out_fake_input_file)
    auto_mng_fake.update_input_file(out_fake_input_file)

    try:
        os.remove(out_fake_input_file)
    except OSError:
        pass
Esempio n. 2
0
def test_update_autoroute_input_file_invalid():
    """
    Checks AutoRoute input file update with invalid input
    """
    main_tests_folder = os.path.dirname(os.path.abspath(__file__))

    original_data_path = os.path.join(main_tests_folder, 'original')
    output_data_path = os.path.join(main_tests_folder, 'output')

    print "TEST 3: UPDATE INPUT FILE WITH FAKE INPUTS"
    auto_mng_fake = AutoRoute(
        "autoroute_exe_path_dummy",
        stream_file=os.path.join(original_data_path, "streamflow_raster.tif"),
        dem_file=os.path.join(output_data_path, "elevation.tif"),
        out_flood_map_shapefile_path="right_here.shp",
    )

    original_fake_input_file = os.path.join(
        output_data_path, "AUTOROUTE_INPUT_FILE-INVALID_INPUTS.txt")
    out_fake_input_file = os.path.join(
        output_data_path, "AUTOROUTE_INPUT_FILE-INVALID_INPUTS.txt")
    copy(original_fake_input_file, out_fake_input_file)
    auto_mng_fake.update_input_file(out_fake_input_file)

    try:
        os.remove(out_fake_input_file)
    except OSError:
        pass
Esempio n. 3
0
def test_update_autoroute_input_file():
    """
    Checks AutoRoute input file generation with valid input
    """
    main_tests_folder = os.path.dirname(os.path.abspath(__file__))
    
    original_data_path = os.path.join(main_tests_folder, 'original')
    output_data_path = os.path.join(main_tests_folder, 'output')

    print "TEST 4: UPDATE VARIABLES IN FILE"
    auto_mng_var = AutoRoute("autoroute_exe_path_dummy",
                             stream_info_file_path="stream_info.txt",
                             dem_raster_file_path="elevation.tif",
                             out_flood_map_shapefile_path="right_here.shp",
                             )

    original_var_input_file = os.path.join(original_data_path, 
                                           "AUTOROUTE_INPUT_FILE-UPDATE_VAR.txt")
    out_var_input_file = os.path.join(output_data_path, 
                                      "AUTOROUTE_INPUT_FILE-UPDATE_VAR.txt")
    copy(original_var_input_file, out_var_input_file)
    auto_mng_var.update_input_file(out_var_input_file)
    updated_input_file_solution = os.path.join(original_data_path, 
                                               "AUTOROUTE_INPUT_FILE-UPDATE_VAR-SOLUTION.txt")
    ok_(fcmp(out_var_input_file, updated_input_file_solution))

    try:
        os.remove(out_var_input_file)
    except OSError:
        pass
Esempio n. 4
0
def test_update_autoroute_input_file():
    """
    Checks AutoRoute input file generation with valid input
    """
    main_tests_folder = os.path.dirname(os.path.abspath(__file__))

    original_data_path = os.path.join(main_tests_folder, 'original')
    output_data_path = os.path.join(main_tests_folder, 'output')

    print "TEST 4: UPDATE VARIABLES IN FILE"
    auto_mng_var = AutoRoute(
        "autoroute_exe_path_dummy",
        stream_info_file_path="stream_info.txt",
        dem_raster_file_path="elevation.tif",
        out_flood_map_shapefile_path="right_here.shp",
    )

    original_var_input_file = os.path.join(
        original_data_path, "AUTOROUTE_INPUT_FILE-UPDATE_VAR.txt")
    out_var_input_file = os.path.join(output_data_path,
                                      "AUTOROUTE_INPUT_FILE-UPDATE_VAR.txt")
    copy(original_var_input_file, out_var_input_file)
    auto_mng_var.update_input_file(out_var_input_file)
    updated_input_file_solution = os.path.join(
        original_data_path, "AUTOROUTE_INPUT_FILE-UPDATE_VAR-SOLUTION.txt")
    ok_(fcmp(out_var_input_file, updated_input_file_solution))

    try:
        os.remove(out_var_input_file)
    except OSError:
        pass