Add tag test

pull/181/head
Louis LCE 2018-01-24 16:19:53 +01:00
parent c80bef0e0d
commit 3d6fa51a7a
1 changed files with 16 additions and 2 deletions

View File

@ -64,6 +64,8 @@ class TestOffline(unittest.TestCase):
m.register_uri('POST', self.domain + 'attributes/downloadSample', json={})
m.register_uri('GET', self.domain + 'tags', json={'Tag': 'foo'})
m.register_uri('POST', self.domain + 'events/upload_sample/1', json={})
m.register_uri('POST', self.domain + 'tags/attachTagToObject', json={})
m.register_uri('POST', self.domain + 'tags/removeTagFromObject', json={})
def test_getEvent(self, m):
self.initURI(m)
@ -440,18 +442,30 @@ class TestOffline(unittest.TestCase):
pymisp = PyMISP(self.domain, self.key)
self.assertEqual((False, None), pymisp.download_samples())
def test_sample_upload(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
upload = pymisp.upload_sample("tmux", "tests/viper-test-files/test_files/tmux" , 1)
def test_get_all_tags(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
self.assertEqual({'Tag': 'foo'}, pymisp.get_all_tags())
def test_tag_event(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
uuid = self.event["Event"]["uuid"]
pymisp.tag(uuid, "foo")
self.assertRaises(pm.PyMISPError, pymisp.tag, "test_uuid", "foo")
self.assertRaises(pm.PyMISPError, pymisp.tag, uuid.replace("a", "z"), "foo")
def test_untag_event(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
uuid = self.event["Event"]["uuid"]
pymisp.untag(uuid, "foo")
if __name__ == '__main__':
unittest.main()