From 8e045efdf39b4e11d9c4459aede1f8d40cab3437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 25 Jul 2017 15:06:37 +0200 Subject: [PATCH] Enforce more validations --- .travis.yml | 2 +- pytaxonomies/api.py | 6 ++++-- pytaxonomies/data/misp-taxonomies | 2 +- tests/tests.py | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34c79b2..c097c5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/pytaxonomies/api.py b/pytaxonomies/api.py index 9ec4bb2..e699fda 100644 --- a/pytaxonomies/api.py +++ b/pytaxonomies/api.py @@ -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) diff --git a/pytaxonomies/data/misp-taxonomies b/pytaxonomies/data/misp-taxonomies index 2723592..c7525b0 160000 --- a/pytaxonomies/data/misp-taxonomies +++ b/pytaxonomies/data/misp-taxonomies @@ -1 +1 @@ -Subproject commit 2723592e2d4d8d179b3cfea161a87412e5604068 +Subproject commit c7525b0260bb3611fa31b555f260c68496d53e48 diff --git a/tests/tests.py b/tests/tests.py index 2923d57..0d50fd9 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -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__":