Skip to content

Commit

Permalink
Change name of test reference data and change assert statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ma595 committed Oct 17, 2024
1 parent d6289b1 commit 9dfe0c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
wget ftp://ftp.fluxdata.org/.ameriflux_downloads/.test/US-ARc_sample_input.zip
wget ftp://ftp.fluxdata.org/.ameriflux_downloads/.test/US-ARc_sample_output.zip
unzip US-ARc_sample_input.zip -d ./tests/data/test_input
unzip US-ARc_sample_output.zip -d ./tests/data/test_output
unzip US-ARc_sample_output.zip -d ./tests/data/test_reference
- name: Run pytest
run: |
export PYTHONPATH=/home/runner/work/ONEFlux/ONEFlux:$PYTHONPATH
Expand Down
16 changes: 8 additions & 8 deletions tests/python/integration/test_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
@pytest.fixture(scope="module")
def get_data():
'''
Utilising python to obtain sample test data. Function currently unused.
as a fixture in this class.
Obtain sample test data using a fixture
Function currently unused.
'''
from zipfile import ZipFile
urllib.urlopen('ftp://ftp.fluxdata.org/.ameriflux_downloads/.test/US-ARc_sample_output.zip')
Expand All @@ -24,7 +24,7 @@ def get_data():

with ZipFile(input_zip) as zi, ZipFile(output_zip) as zo:
zi.extractall(path='tests/data/test_input')
zo.extractall(path='tests/data/test_output')
zo.extractall(path='tests/data/test_reference')

def equal_csv(csv_1, csv_2):
'''
Expand Down Expand Up @@ -55,6 +55,7 @@ def setup_data():
'''
try:
os.mkdir('tests/integration/data/step_10')
os.mkdir('tests/data/test_reference')
except OSError as e:
if e.errno == errno.EEXIST:
print("directory exists")
Expand All @@ -63,7 +64,7 @@ def setup_data():

copy_tree('tests/data/test_input/', testdata)

refoutdir = 'tests/data/test_output/US-ARc_sample_output'
refoutdir = 'tests/data/test_reference/US-ARc_sample_output'

copy_tree(os.path.join(refoutdir, '07_meteo_proc'), \
os.path.join(testdata, '07_meteo_proc'))
Expand All @@ -78,7 +79,7 @@ def test_run_partition_nt(setup_data):
Run partition_nt on single percentile.
'''
datadir = "./tests/python/integration/input/step_10/"
refoutdir = "./tests/data/test_output/"
refoutdir = "./tests/data/test_reference/"
siteid = "US-ARc"
sitedir = "US-ARc_sample_input"
years = [2005] # years = [2005, 2006]
Expand All @@ -95,7 +96,7 @@ def test_run_partition_nt(setup_data):
run_python(datadir=datadir, siteid=siteid, sitedir=sitedir, prod_to_compare=PROD_TO_COMPARE,
perc_to_compare=PERC_TO_COMPARE, years_to_compare=years)

# check whether csv of "output" is same as csv of reference
# check whether csv of output in input directory is same as csv of reference

# the generated output is actually in the "input" directory.
rootdir = os.path.join(datadir, sitedir, "10_nee_partition_nt")
Expand All @@ -107,10 +108,9 @@ def test_run_partition_nt(setup_data):
ref_nee_y_files = glob.glob(os.path.join(refoutdir, "nee_y_1.25_US-ARc_2005*"))

assert len(nee_y_files) == len(ref_nee_y_files)
retval = True
for f, b in zip(nee_y_files, ref_nee_y_files):
print(f, b)
assert equal_csv(f, b) == True
assert equal_csv(f, b)

# clean up data.
# shutil.rmtree(datadir)

0 comments on commit 9dfe0c8

Please sign in to comment.