Skip to content

Commit

Permalink
test next
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Sep 28, 2023
1 parent 4c7610f commit 33ba2a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,26 @@ def add_row(self, **kwargs):
data, row_id, enforce_unique_id = popargs('data', 'id', 'enforce_unique_id', kwargs)
data = data if data is not None else kwargs

bad_data = []
extra_columns = set(list(data.keys())) - set(list(self.__colids.keys()))
missing_columns = set(list(self.__colids.keys())) - set(list(data.keys()))

for colname, colnum in self.__colids.items():
if colname not in data:
raise ValueError("column '%s' missing" % colname)
col = self.__df_cols[colnum]
if isinstance(col, VectorIndex):
continue
else:
if col.term_set is not None:
if col.term_set.validate(term=data[colname]):
continue
else:
bad_data.append(data[colname])

if len(bad_data)!=0:
msg = ('"%s" is not in the term set.' % ', '.join([str(item) for item in bad_data]))
raise ValueError(msg)

# check to see if any of the extra columns just need to be added
if extra_columns:
Expand Down
11 changes: 3 additions & 8 deletions tests/unit/test_term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ def test_wrapper_extend_error(self):
data_obj.extend(['bad_data'])

def test_wrapper_next(self):
data_values = ['Homo sapiens', 'Mus musculus']
data_obj = VectorData(name='species', description='...', data=self.wrapped_list)
data_obj.extend(['Mus musculus'])

counter = 0
for i in data_obj.data:
self.assertEqual(i, data_values[counter])
counter +=1
with self.assertRaises(AttributeError):
next(self.wrapped_list)

0 comments on commit 33ba2a5

Please sign in to comment.