Update tests

pull/111/head
Raphaël Vinot 2017-08-25 17:14:33 +02:00
parent f06bfd310b
commit 38a488c70c
2 changed files with 40 additions and 6 deletions

View File

@ -16,8 +16,11 @@ install:
- pip install -U nose
- pip install coveralls
- pip install codecov
- pip install requests-mock
- pip install requests-mock pytest
- pip install .
- pushd tests
- git clone https://github.com/viper-framework/viper-test-files.git
- popd
script:
- nosetests --with-coverage --cover-package=pymisp tests/test_offline.py

View File

@ -13,6 +13,9 @@ from pymisp import MISPEvent
from pymisp import EncodeUpdate
from pymisp import EncodeFull
from pymisp import MISPEncode
from pymisp.tools import make_binary_objects
@requests_mock.Mocker()
class TestOffline(unittest.TestCase):
@ -220,5 +223,33 @@ class TestOffline(unittest.TestCase):
p.add_internal_other(evt, 'foobar')
p.add_attachment(evt, "testFile")
def make_objects(self, path):
to_return = {'objects': [], 'references': []}
fo, peo, seos = make_binary_objects(path)
if seos:
for s in seos:
to_return['objects'].append(s)
if s.references:
to_return['references'] += s.references
if peo:
to_return['objects'].append(peo)
if peo.references:
to_return['references'] += peo.references
if fo:
to_return['objects'].append(fo)
if fo.references:
to_return['references'] += fo.references
return json.dumps(to_return, cls=MISPEncode)
def test_objects(self, m):
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
for path in paths:
json_blob = self.make_objects(os.path.join('tests',
'viper-test-files', 'test_files', path))
print(json_blob)
if __name__ == '__main__':
unittest.main()