Improve has_entries, fix tests.

pull/2/head
Raphaël Vinot 2016-10-14 18:24:21 +02:00
parent 9206716c88
commit 14cdb9183a
2 changed files with 10 additions and 9 deletions

View File

@ -135,8 +135,10 @@ class Taxonomy(collections.Mapping):
return to_return
def has_entries(self):
if self.predicates.values() and list(self.predicates.values())[0].entries:
return True
if self.predicates.values():
for p in self.predicates.values():
if p.entries:
return True
return False
def __str__(self):

View File

@ -50,13 +50,12 @@ class TestPyTaxonomies(unittest.TestCase):
self.taxonomies.search('phish', expanded=True)
def test_print_classes(self):
for t in self.taxonomies.values():
if not t.has_entries():
continue
tax = list(t.values())[0]
print(tax)
pred = list(tax.values())[0]
print(pred)
for taxonomy in self.taxonomies.values():
print(taxonomy)
for predicate in taxonomy.values():
print(predicate)
for entry in predicate.values():
print(entry)
def test_amountEntries(self):
list(self.taxonomies.values())[0].amount_entries()