Skip to content

Commit

Permalink
fs_metadata plugin: test bugfix for updated template
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Sep 12, 2023
1 parent c24df3f commit 60eef67
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_object(self, uid):

def get_analysis(self, uid, plugin):
if uid == self.fw.uid and plugin == AnalysisPlugin.NAME:
return {'result': {'files': [{'key': b64_encode('some_file'), 'test_result': 'test_value'}]}}
return {'result': {'files': [{'key': b64_encode('some_file'), 'mode': '1337'}]}}
return None

@contextmanager
Expand Down Expand Up @@ -124,14 +124,14 @@ def setup(self):
app = Flask(__name__)
app.config.from_object(__name__)
app.config['TESTING'] = True
app.jinja_env.filters['replace_uid_with_hid'] = lambda x: x
for filter_ in ('replace_uid_with_hid', 'nice_unix_time', 'octal_to_readable'):
app.jinja_env.filters[filter_] = lambda x: x
self.plugin_routes = routes.PluginRoutes(app, db=DbMock, intercom=None, status=None)
self.test_client = app.test_client()

def test_get_analysis_results_of_parent_fo(self):
rv = self.test_client.get('/plugins/file_system_metadata/ajax/foo')
assert 'test_result' in rv.data.decode()
assert 'test_value' in rv.data.decode()
assert '1337' in rv.data.decode()


class TestFileSystemMetadataRoutesRest(TestCase):
Expand All @@ -153,7 +153,8 @@ def test_get_rest(self):
result = self.test_client.get('/plugins/file_system_metadata/rest/foo').json
assert AnalysisPlugin.NAME in result
assert 'some_file' in result[AnalysisPlugin.NAME]
assert 'test_result' in result[AnalysisPlugin.NAME]['some_file']
assert 'mode' in result[AnalysisPlugin.NAME]['some_file']
assert result[AnalysisPlugin.NAME]['some_file']['mode'] == '1337'

def test_get_rest__no_result(self):
result = self.test_client.get('/plugins/file_system_metadata/rest/not_found').json
Expand Down

0 comments on commit 60eef67

Please sign in to comment.