Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Oct 19, 2023
1 parent d516c7f commit 98c18b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hdmf/term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def __init__(self,
self.name = self.view.schema.name

Check warning on line 56 in src/hdmf/term_set.py

View check run for this annotation

Codecov / codecov/patch

src/hdmf/term_set.py#L56

Added line #L56 was not covered by tests
self.sources = self.view.schema.prefixes

def __repr__(self): # pragma: no cover
def __repr__(self):
re = "Schema Path: %s\n" % self.term_schema_path
re += "Sources: " + ", ".join(list(self.sources.keys()))
return re

Check warning on line 62 in src/hdmf/term_set.py

View check run for this annotation

Codecov / codecov/patch

src/hdmf/term_set.py#L60-L62

Added lines #L60 - L62 were not covered by tests

def _repr_html_(self): # pragma: no cover
def _repr_html_(self):
re = "<p><b>" + "Schema Path: " + "</b>" + self.term_schema_path + "<br>" + "</p>"
re += "<p><b>" + "Sources: " + "</b>" + ", ".join(list(self.sources.keys())) + "</p>"

Check warning on line 66 in src/hdmf/term_set.py

View check run for this annotation

Codecov / codecov/patch

src/hdmf/term_set.py#L65-L66

Added lines #L65 - L66 were not covered by tests
return re
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ def test_termset_setup(self):
self.assertEqual(termset.name, 'Species')
self.assertEqual(list(termset.sources), ['NCBI_TAXON'])

def test_repr(self):
termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml')
output = 'Schema Path: tests/unit/example_test_term_set.yaml\nSources: NCBI_TAXON'
self.assertEqual(repr(termset), output)

def test_repr_html(self):
termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml')
output = '<p><b>Schema Path: </b>tests/unit/example_test_term_set.yaml<br></p><p><b>Sources: </b>NCBI_TAXON</p>'
self.assertEqual(termset._repr_html_(), output)

def test_view_set(self):
termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml')
expected = ['Homo sapiens', 'Mus musculus', 'Ursus arctos horribilis', 'Myrmecophaga tridactyla']
Expand Down

0 comments on commit 98c18b2

Please sign in to comment.