new: [Sightings] Delete method

Fix #230
pull/422/head
Raphaël Vinot 2019-07-19 11:41:56 +02:00
parent 1a9b598b96
commit f5cbb417c8
2 changed files with 10 additions and 0 deletions

View File

@ -447,6 +447,12 @@ class ExpandedPyMISP(PyMISP):
s.from_dict(**new_sighting) s.from_dict(**new_sighting)
return s return s
def delete_sighting(self, sighting: Union[MISPSighting, int, str, UUID]):
'''Delete a sighting from a MISP instance'''
sighting_id = self.__get_uuid_or_id_from_abstract_misp(sighting)
response = self._prepare_request('POST', f'sightings/delete/{sighting_id}')
return self._check_response(response, expect_json=True)
# ## END Sighting ### # ## END Sighting ###
# ## BEGIN Tags ### # ## BEGIN Tags ###

View File

@ -798,6 +798,10 @@ class TestComprehensive(unittest.TestCase):
s = self.user_misp_connector.sightings(second.attributes[0], self.test_org.id, pythonify=True) s = self.user_misp_connector.sightings(second.attributes[0], self.test_org.id, pythonify=True)
self.assertEqual(len(s), 1) self.assertEqual(len(s), 1)
self.assertEqual(s[0].org_id, self.test_org.id) self.assertEqual(s[0].org_id, self.test_org.id)
# Delete sighting
r = self.user_misp_connector.delete_sighting(s[0])
self.assertEqual(r['message'], 'Sighting successfuly deleted.')
finally: finally:
# Delete event # Delete event
self.admin_misp_connector.delete_event(first.id) self.admin_misp_connector.delete_event(first.id)