Enforce more validations

pull/2/head
Raphaël Vinot 2017-07-25 15:06:37 +02:00
parent 67063b62bb
commit 8e045efdf3
4 changed files with 7 additions and 6 deletions

View File

@ -18,7 +18,7 @@ install:
- git clone https://github.com/MISP/misp-taxonomies.git
script:
- nosetests --with-coverage --cover-package=pytaxonomies
- nosetests --with-coverage --cover-package=pytaxonomies -d
after_success:
- codecov

View File

@ -5,6 +5,7 @@ import json
import os
import collections
import re
import sys
from json import JSONEncoder
try:
@ -107,7 +108,7 @@ class Taxonomy(collections.Mapping):
temp_entry = {'value': entry.value}
if entry.expanded:
temp_entry['expanded'] = entry.expanded
if entry.numerical_value:
if entry.numerical_value is not None:
temp_entry['numerical_value'] = entry.numerical_value
if entry.colour:
temp_entry['colour'] = entry.colour
@ -188,7 +189,8 @@ class Taxonomy(collections.Mapping):
class Taxonomies(collections.Mapping):
def __init__(self, manifest_url='https://raw.githubusercontent.com/MISP/misp-taxonomies/master/MANIFEST.json',
manifest_path=os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'misp-taxonomies', 'MANIFEST.json')):
manifest_path=os.path.join(os.path.abspath(os.path.dirname(sys.modules['pytaxonomies'].__file__)),
'data', 'misp-taxonomies', 'MANIFEST.json')):
if manifest_path:
self.loader = self.__load_path
self.manifest = self.loader(manifest_path)

@ -1 +1 @@
Subproject commit 2723592e2d4d8d179b3cfea161a87412e5604068
Subproject commit c7525b0260bb3611fa31b555f260c68496d53e48

View File

@ -5,7 +5,6 @@ import json
import unittest
from pytaxonomies import Taxonomies, EncodeTaxonomies
import pytaxonomies.api
import os
class TestPyTaxonomies(unittest.TestCase):
@ -78,7 +77,7 @@ class TestPyTaxonomies(unittest.TestCase):
self.maxDiff = None
for key, t in self.taxonomies_offline.items():
out = t._json()
self.assertCountEqual(out, self.loaded_tax[t.name])
self.assertDictEqual(out, self.loaded_tax[t.name])
if __name__ == "__main__":