Skip to content

Commit

Permalink
fix csv file qa tests
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 12, 2024
1 parent 3ea0f79 commit ee3bd9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions py/desidatamodel/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,15 @@ def read_column_descriptions(filename):

with open(filename) as fp:
header = fp.readline().strip()
correct_header = 'Name,Type,Units,Description'
correct_header = 'Name,Type,Units,FullDescription,Description'
if header != correct_header:
raise ValueError(f'{filename} header {header} should be {correct_header}')
raise ValueError(f'{filename} header {header} should be {correct_header}.')

coldesc = dict()
csvreader = csv.reader(fp)
for row in csvreader:
name, dtype, units, desc = row
coldesc[name] = dict(Type=dtype, Units=units, Description=desc)
name, dtype, units, dm_desc, fits_desc = row
coldesc[name] = dict(Type=dtype, Units=units, Description=dm_desc)

return coldesc

Expand Down
8 changes: 4 additions & 4 deletions py/desidatamodel/test/t/column_descriptions.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name,Type,Units,Description
target,char[20],,Target Name
V_mag,float32,nanomaggy,V-band nanomaggy to test units
vdisp,float64,m/s,Velocity dispersion
Name,Type,Units,FullDescription,Description
target,char[20],,Target Name,Target Name
V_mag,float32,nanomaggy,V-band nanomaggy to test units,V-band flux
vdisp,float64,m/s,Velocity dispersion,Vel Disp
6 changes: 5 additions & 1 deletion py/desidatamodel/test/test_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ def test_Stub_with_descriptions(self, mock_log):

# incorrect format column description file
baddescfile = self.test_files / 'bad_column_descriptions.csv'
with self.assertRaises(ValueError):
header = 'Name,dtype,Units,Description'
correct_header = 'Name,Type,Units,FullDescription,Description'
with self.assertRaises(ValueError) as exc:
stub = Stub(filename, description_file=baddescfile)
lines = str(stub)
self.assertEqual(exc.exception.args[0],
f'{str(baddescfile)} header {header} should be {correct_header}.')

0 comments on commit ee3bd9b

Please sign in to comment.