mirror of https://github.com/MISP/PyTaxonomies
Fix encodings in python2, improve coverage
parent
18ccef2bd8
commit
da5d552a58
|
@ -11,8 +11,10 @@ class Entry():
|
|||
|
||||
def __init__(self, value, expanded, description):
|
||||
self.value = value
|
||||
self.expanded = expanded
|
||||
self.description = description
|
||||
self.expanded = expanded.encode('utf-8')
|
||||
self.description = None
|
||||
if description:
|
||||
self.description = description.encode('utf-8')
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
@ -22,7 +24,9 @@ class Predicate(collections.Mapping):
|
|||
|
||||
def __init__(self, predicate, description, entries):
|
||||
self.predicate = predicate
|
||||
self.description = description
|
||||
self.description = None
|
||||
if description:
|
||||
self.description = description.encode('utf-8')
|
||||
self.entries = {}
|
||||
if entries:
|
||||
self.__init_entries(entries)
|
||||
|
|
|
@ -31,6 +31,14 @@ class TestPyTaxonomies(unittest.TestCase):
|
|||
def test_local(self):
|
||||
Taxonomies(manifest_path="./misp-taxonomies/MANIFEST.json")
|
||||
|
||||
def test_print_classes(self):
|
||||
tax = list(self.taxonomies.values())[0]
|
||||
print(tax)
|
||||
pred = list(tax.values())[0]
|
||||
print(pred)
|
||||
entry = list(pred.values())[0]
|
||||
print(entry)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue