From 0134e2a9e307593c16e5ec9b5e40a58cfdf54ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 17 Aug 2016 18:21:50 +0200 Subject: [PATCH] Initial version of the offline TestCases Related #56 --- tests/test_offline.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_offline.py diff --git a/tests/test_offline.py b/tests/test_offline.py new file mode 100644 index 0000000..fd9fdf6 --- /dev/null +++ b/tests/test_offline.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import requests_mock +import json + +from pymisp import PyMISP + + +@requests_mock.Mocker() +class TestOffline(object): + + def setUp(self): + self.domain = 'http://misp.local/' + self.key = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + self.event = json.load(open('misp_event.json', 'r')) + self.types = json.load(open('describeTypes.json', 'r')) + + def initURI(self, m): + m.register_uri('GET', self.domain + 'servers/getVersion', json={"version": "2.4.50"}) + m.register_uri('GET', self.domain + 'attributes/describeTypes.json', json=self.types) + m.register_uri('GET', self.domain + 'events/2', json=self.event) + + def test_getEvent(self, m): + self.initURI(m) + pymisp = PyMISP(self.domain, self.key, debug=True) + e = pymisp.get_event(2) + print(e)