mirror of https://github.com/MISP/PyMISPGalaxies
Add test for UnableToRevertMachinetag
parent
d146ebba88
commit
b4ba8dcf84
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .api import Galaxies, Clusters, EncodeGalaxies
|
||||
from .api import Galaxies, Clusters, EncodeGalaxies, UnableToRevertMachinetag
|
||||
|
|
|
@ -244,8 +244,8 @@ class Clusters(collections.Mapping):
|
|||
return [cluster.machinetags() for cluster in self.values()]
|
||||
|
||||
def revert_machinetag(self, machinetag):
|
||||
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
||||
try:
|
||||
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
||||
cluster = self.get(cluster_type)
|
||||
value = cluster[cluster_value]
|
||||
return cluster, value
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
from pymispgalaxies import Galaxies, Clusters
|
||||
from pymispgalaxies import Galaxies, Clusters, UnableToRevertMachinetag
|
||||
from glob import glob
|
||||
import os
|
||||
import json
|
||||
|
@ -59,6 +59,8 @@ class TestPyMISPGalaxies(unittest.TestCase):
|
|||
|
||||
def test_revert_machinetag(self):
|
||||
self.assertEqual(len(self.clusters.revert_machinetag('misp-galaxy:tool="Babar"')), 2)
|
||||
with self.assertRaises(UnableToRevertMachinetag):
|
||||
self.clusters.revert_machinetag('blah')
|
||||
|
||||
def test_len(self):
|
||||
self.assertIsNot(len(self.clusters), 0)
|
||||
|
|
Loading…
Reference in New Issue