-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/libmagic dependency injection #23
Feature/libmagic dependency injection #23
Conversation
Thanks! I feel like there's a lot of duplication, and I'm a bit concerned by the big number of new lines of code. For example, this fragment: m = MagicMock()
m.side_effect = [
', '.join([
'PDF document',
'version 1.4',
]),
'application/pdf',
]
self.karton = Classifier(
magic=m, config=self.config, backend=self.backend
) with a good helper method could be shortened to: self.karton = mock_classifier(['PDF document', 'version 1.4'], "application/pdf") And this fragment: resource = Resource('file.pdf', b'feeddecaf\n', sha256='sha256')
task = Task({
'type': 'sample',
'kind': 'raw',
})
task.add_payload('sample', resource)
res = self.run_task(task) could be shortened to: res = classify("file.pdf") this will add up over all the repeated invocations. Do you think it makes sense? Also do you mind running |
Let me clean up the code just a bit more. As there seem to be some issues after merging in changes from @msm-code . |
* add basic classifier test * refactor archive tests * refactor document tests * refactor misc tests * refactor runnable tests * refactor script tests
770f695
to
f323bf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests still feel a bit repetitive, but I think they're good - and I like the dependency injection approach here. LGTM.
This change set adds the magic description (as a payload) and mime type (as a header) to the classifier result.
Testing has been completely reworked and uses dependency injection to make
libmagic
results stable across various platforms.