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 == []
def test_window_string(): state = State() assert state.get_window_string() == '' state.set_window(-1, 4, 1, 2) nums = list(map(int, state.get_window_string().split(' '))) assert len(nums) == 4 assert nums[0] == -1 assert nums[1] == 4 assert nums[2] == 1 assert nums[3] == 2
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]
def test_process_satellite_with_gdal(mock_call): state = State() state.set_window(0, 7, 2, 1) status = SatelliteStatus(0, ['test.tif', 'test2.tif'], state) building.process_satellite_with_gdal(status) outpath = path.join(building.FINALIZED_DIR, building.INTERMEDIATE_SATELLITE_FORMAT.format(0)) expected_command = 'gdalwarp -tr 10 10 -te_srs EPSG:4326 -t_srs EPSG:3857 -r bilinear -te 0 1 2 7 test.tif test2.tif {}'.format( outpath) mock_call.assert_called_once_with(expected_command, status, False) assert status.current_files == [outpath]
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']
def test_has_window(): state = State() assert not state.has_window() state.set_window(1, 2, 3, 4) assert state.has_window()