diff --git a/.travis.yml b/.travis.yml index bdaffec..74bd193 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ install: - pip install coveralls - pip install codecov - pip install . + - git clone https://github.com/MISP/misp-taxonomies.git script: - nosetests --with-coverage --cover-package=pytaxonomies diff --git a/pytaxonomies/api.py b/pytaxonomies/api.py index 8f61d50..3d4d8ef 100644 --- a/pytaxonomies/api.py +++ b/pytaxonomies/api.py @@ -106,6 +106,8 @@ class Taxonomies(collections.Mapping): if manifest_path: self.url = os.path.dirname(os.path.realpath(manifest_path)) + else: + self.url = self.manifest['url'] self.version = self.manifest['version'] self.license = self.manifest['license'] self.description = self.manifest['description'] @@ -120,7 +122,7 @@ class Taxonomies(collections.Mapping): return requests.get(url).json() def __make_uri(self, taxonomy_name): - return '{}{}/{}'.format(self.manifest['url'], taxonomy_name, self.manifest['path']) + return '{}/{}/{}'.format(self.url, taxonomy_name, self.manifest['path']) def __init_taxonomies(self): self.taxonomies = {} diff --git a/tests/tests.py b/tests/tests.py index 282d039..8137853 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -13,5 +13,24 @@ class TestPyTaxonomies(unittest.TestCase): def test_print(self): print(self.taxonomies) + def test_expanded_print(self): + for name in self.taxonomies.taxonomies_names: + tax = self.taxonomies.get(name) + print(tax.print_expanded_entries()) + + def test_len(self): + len(self.taxonomies) + + def test_iter(self): + for n, t in self.taxonomies.items(): + len(t) + t.amount_entries() + for p, value in t.items(): + continue + + def test_local(self): + Taxonomies(manifest_path="./misp-taxonomies/MANIFEST.json") + + if __name__ == "__main__": unittest.main()