mirror of https://github.com/MISP/PyTaxonomies
Improve has_entries, fix tests.
parent
9206716c88
commit
14cdb9183a
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue