2020-06-14 18:36:40 +02:00
|
|
|
#!/usr/bin/env python
|
2024-01-17 13:34:56 +01:00
|
|
|
|
|
|
|
from __future__ import annotations
|
2020-06-14 18:36:40 +02:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
import json
|
|
|
|
from pymisp.tools import FileObject
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
|
|
class TestFileObject(unittest.TestCase):
|
2024-02-01 14:40:12 +01:00
|
|
|
def test_mimeType(self) -> None:
|
2020-06-14 18:36:40 +02:00
|
|
|
file_object = FileObject(filepath=pathlib.Path(__file__))
|
|
|
|
attributes = json.loads(file_object.to_json())['Attribute']
|
|
|
|
mime = next(attr for attr in attributes if attr['object_relation'] == 'mimetype')
|
|
|
|
# was "Python script, ASCII text executable"
|
2020-09-16 12:07:55 +02:00
|
|
|
# libmagic on linux: 'text/x-python'
|
|
|
|
# libmagic on os x: 'text/x-script.python'
|
|
|
|
self.assertEqual(mime['value'][:7], 'text/x-')
|
|
|
|
self.assertEqual(mime['value'][-6:], 'python')
|