re #BITBUCKET-3626 replacing manual table check with pygeoprocessing.testing.assert_csv_equal
This commit is contained in:
parent
586b1c1beb
commit
cb99c08ed4
|
@ -54,31 +54,10 @@ class CropProductionTests(unittest.TestCase):
|
|||
|
||||
result_table_path = os.path.join(
|
||||
args['workspace_dir'], 'aggregate_results.csv')
|
||||
from natcap.invest import utils
|
||||
result_table = utils.build_lookup_from_csv(
|
||||
result_table_path, 'id', to_lower=True, numerical_cast=True)
|
||||
|
||||
expected_result_table_path = os.path.join(
|
||||
TEST_DATA_PATH, 'expected_aggregate_results.csv')
|
||||
|
||||
expected_result_table = utils.build_lookup_from_csv(
|
||||
expected_result_table_path, 'id', to_lower=True,
|
||||
numerical_cast=True)
|
||||
|
||||
for id_key in expected_result_table:
|
||||
if id_key not in result_table:
|
||||
self.fail("Expected ID %s in result table" % id_key)
|
||||
for column_key in expected_result_table[id_key]:
|
||||
if column_key not in result_table[id_key]:
|
||||
self.fail(
|
||||
"Expected column %s in result table" % column_key)
|
||||
# The tolerance of 3 digits after the decimal was determined by
|
||||
# experimentation
|
||||
tolerance_places = 3
|
||||
numpy.testing.assert_almost_equal(
|
||||
expected_result_table[id_key][column_key],
|
||||
result_table[id_key][column_key],
|
||||
decimal=tolerance_places)
|
||||
pygeoprocessing.testing.assert_csv_equal(
|
||||
expected_result_table_path, result_table_path)
|
||||
|
||||
@scm.skip_if_data_missing(SAMPLE_DATA_PATH)
|
||||
@scm.skip_if_data_missing(MODEL_DATA_PATH)
|
||||
|
@ -166,28 +145,7 @@ class CropProductionTests(unittest.TestCase):
|
|||
|
||||
result_table_path = os.path.join(
|
||||
args['workspace_dir'], 'aggregate_results.csv')
|
||||
from natcap.invest import utils
|
||||
result_table = utils.build_lookup_from_csv(
|
||||
result_table_path, 'id', to_lower=True, numerical_cast=True)
|
||||
|
||||
expected_result_table_path = os.path.join(
|
||||
TEST_DATA_PATH, 'expected_regression_aggregate_results.csv')
|
||||
|
||||
expected_result_table = utils.build_lookup_from_csv(
|
||||
expected_result_table_path, 'id', to_lower=True,
|
||||
numerical_cast=True)
|
||||
|
||||
for id_key in expected_result_table:
|
||||
if id_key not in result_table:
|
||||
self.fail("Expected ID %s in result table" % id_key)
|
||||
for column_key in expected_result_table[id_key]:
|
||||
if column_key not in result_table[id_key]:
|
||||
self.fail(
|
||||
"Expected column %s in result table" % column_key)
|
||||
# The tolerance of 3 digits after the decimal was determined by
|
||||
# experimentation
|
||||
tolerance_places = 3
|
||||
numpy.testing.assert_almost_equal(
|
||||
expected_result_table[id_key][column_key],
|
||||
result_table[id_key][column_key],
|
||||
decimal=tolerance_places)
|
||||
pygeoprocessing.testing.assert_csv_equal(
|
||||
expected_result_table_path, result_table_path)
|
||||
|
|
Loading…
Reference in New Issue