コード例 #1
0
def test_process_heightfiles_with_gdal_with_no_files(mock_call):
    state = State()
    state.set_window(0, 7, 2, 1)
    status = HeightMapStatus(0, [], state)
    building.process_heightfiles_with_gdal(status)
    mock_call.assert_not_called()
    assert status.current_files == []
コード例 #2
0
def test_call_command_no_debug(mock_popen):
    status = HeightMapStatus(0, 'test.txt', DummyState())
    mock_popen.return_value.__enter__.return_value.communicate.return_value = (
        b'test output', b'test error')
    building.call_command('mycommand --do-test -- -1 2 3', status, False)
    mock_popen.assert_called_once_with('mycommand --do-test -- -1 2 3',
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
    assert 'mycommand' not in str(status)
    assert 'test output' not in str(status)
    assert 'test error' in str(status)
コード例 #3
0
def test_process_heightfiles_with_gdal(mock_call):
    state = State()
    state.set_window(0, 7, 2, 1)
    status = HeightMapStatus(0, ['test.txt'], state)
    building.process_heightfiles_with_gdal(status)
    outpath = path.join(building.BUILD_DIR,
                        building.INTERMEDIATE_HEIGHT_FILENAME)
    expected_command = 'gdalwarp -tr 10 10 -te_srs EPSG:4326 -t_srs EPSG:3857 -r bilinear -te 0 1 2 7 test.txt {}'.format(
        outpath)
    mock_call.assert_called_once_with(expected_command, status, False)
    assert status.current_files == [outpath]
コード例 #4
0
def test_check_projection_window(mock_forfile, mock_call):
    ginfo_for_testing = Gdalinfo()
    ginfo_for_testing.minX = -99
    ginfo_for_testing.minY = -99
    ginfo_for_testing.maxX = 99
    ginfo_for_testing.maxY = 3
    mock_forfile.return_value = ginfo_for_testing
    state = State()
    state.set_window(0, 7, 2, 1)
    status = HeightMapStatus(0, ['test.txt'], state)
    building.check_projection_window(status)
    mock_forfile.assert_called_once_with('test.txt')
    assert status.current_files == ['test.txt']
コード例 #5
0
def test_translate_heightfile(mock_call):
    def add_mock_files(a, b, c):
        open(building.get_output_path('test.txt', 'hdr'), 'w').close()
        open(building.get_output_path('test2.txt', 'hdr'), 'w').close()

    mock_call.side_effect = add_mock_files
    building.init_build()
    status = HeightMapStatus(2, ['test.txt', 'test2.txt'], DummyState())
    building.translate_heightfiles(status)
    outpath1 = path.join(building.FINALIZED_DIR,
                         building.FINAL_HEIGHT_FILENAME_FORMAT.format(0))
    metapath1 = path.join(building.FINALIZED_DIR,
                          building.FINAL_HEIGHT_METADATA_FORMAT.format(0))
    outpath2 = path.join(building.FINALIZED_DIR,
                         building.FINAL_HEIGHT_FILENAME_FORMAT.format(1))
    metapath2 = path.join(building.FINALIZED_DIR,
                          building.FINAL_HEIGHT_METADATA_FORMAT.format(1))
    expected_command = 'gdal_translate -of ENVI test.txt {}'.format(outpath1)
    expected_command_2 = 'gdal_translate -of ENVI test2.txt {}'.format(
        outpath2)
    mock_call.assert_any_call(expected_command, status, False)
    mock_call.assert_any_call(expected_command_2, status, False)
    assert status.result_files == [outpath1, metapath1, outpath2, metapath2]
コード例 #6
0
def test_check_projection_window_when_no_window(mock_call):
    status = HeightMapStatus(0, ['test.txt', 'test2.txt'], State())
    building.check_projection_window(status)
    mock_call.assert_not_called()
    assert status.current_files == []