12
12
import pandas as pd
13
13
14
14
15
- DATADIR = "/home/dav/SPECCHIO-QGIS-python/DATA/"
16
- #DATADIR = "/home/dvalters/Projects/SPECCHIO/DATA/"
17
-
18
- TEST_PRN_DIR = ("/home/dav/SPECCHIO-QGIS-python/DATA/ES/field_scale/"
19
- "ES_F1_2017/plot_scale_data/LAI/" )
20
- #TEST_PRN_DIR = ("/home/dvalters/Projects/SPECCHIO/DATA/ES/field_scale/"
21
- # "ES_F1_2017/plot_scale_data/LAI/")
22
-
23
-
24
-
25
15
dataframes = {}
26
16
27
17
# Names of soil sheets in the Soils directory
@@ -38,8 +28,8 @@ def file_and_dict_name(dirname, fname):
38
28
return (filefullname , dictname )
39
29
40
30
41
- def extract_dataframes ():
42
- for (dirname , subdirs , files ) in os .walk (DATADIR ):
31
+ def extract_dataframes (directory ):
32
+ for (dirname , subdirs , files ) in os .walk (directory ):
43
33
# print('[' + dirname + ']')
44
34
for fname in files :
45
35
# Only match "xlsx" files, exclude recovery/backup files
@@ -116,6 +106,17 @@ class PRNdata(object):
116
106
117
107
118
108
class TestParser (unittest .TestCase ):
109
+
110
+ #DATADIR = "/home/dav/SPECCHIO-QGIS-python/DATA/"
111
+ #DATADIR = "/home/dvalters/Projects/SPECCHIO/DATA/"
112
+ DATADIR = "/home/centos/Python/test/DATA/"
113
+
114
+ #TEST_PRN_DIR = ("/home/dav/SPECCHIO-QGIS-python/DATA/ES/field_scale/"
115
+ # "ES_F1_2017/plot_scale_data/LAI/")
116
+ #TEST_PRN_DIR = ("/home/dvalters/Projects/SPECCHIO/DATA/ES/field_scale/"
117
+ # "ES_F1_2017/plot_scale_data/LAI/")
118
+ TEST_PRN_DIR = ("/home/centos/Python/test/DATA/ES/field_scale/"
119
+ "ES_F1_2017/plot_scale_data/LAI/" )
119
120
120
121
def test_correct_files_parsed (self ):
121
122
@@ -128,27 +129,27 @@ def test_correct_files_parsed(self):
128
129
129
130
def test_PRN_parsing_columns (self ):
130
131
"""PRN data should have nine columns if correctly ingested"""
131
- filefullname = TEST_PRN_DIR + "20170714_LAI.PRN"
132
+ filefullname = self . TEST_PRN_DIR + "20170714_LAI.PRN"
132
133
extract_PRN_format (filefullname , "TEST_PRN_dict" )
133
134
self .assertEqual (len (dataframes ['TEST_PRN_dict' ].columns ), 9 )
134
135
135
136
def test_PRN_parsing_rows (self ):
136
137
"""PRN data should have 261 rows if correctly ingested"""
137
- filefullname = TEST_PRN_DIR + "20170714_LAI.PRN"
138
+ filefullname = self . TEST_PRN_DIR + "20170714_LAI.PRN"
138
139
extract_PRN_format (filefullname , "TEST_PRN_dict" )
139
140
self .assertEqual (len (dataframes ['TEST_PRN_dict' ]), 261 )
140
141
141
142
def test_PRN_line (self ):
142
143
"""Test a line has been correctly parsed"""
143
- filefullname = TEST_PRN_DIR + "20170714_LAI.PRN"
144
+ filefullname = self . TEST_PRN_DIR + "20170714_LAI.PRN"
144
145
extract_PRN_format (filefullname , "TEST_PRN_dict" )
145
146
146
147
df_line = dataframes ['TEST_PRN_dict' ].loc [0 ]
147
148
148
149
def test_generate_PRN_lines (self ):
149
150
"""Test that we can strip and print the PRN text file lines.
150
151
Print statement around next() is removed now."""
151
- reader = generate_goodPRNline (TEST_PRN_DIR + "20170714_LAI.PRN" )
152
+ reader = generate_goodPRNline (self . TEST_PRN_DIR + "20170714_LAI.PRN" )
152
153
while True :
153
154
try :
154
155
next (reader )
0 commit comments