Skip to content

Commit

Permalink
Fix regression with saving results (#40)
Browse files Browse the repository at this point in the history
* Fix regression with saving results

* Correct CHANGELOG

* Add testcase
  • Loading branch information
inverse authored Mar 11, 2021
1 parent 3b2c7f7 commit 40ebe78
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.2.1 (2020-03-11)

### Fixed

- Fixed regression with saving results object (#40)

## v2.2.0 (2020-03-05)

### Added
Expand Down
2 changes: 1 addition & 1 deletion tell_me_your_secrets/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.0'
__version__ = '2.2.1'
2 changes: 1 addition & 1 deletion tell_me_your_secrets/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def process(self, filtered_files: list):

def write_results_to_file(self):
if len(self.matched_signatures) > 0:
write_df = DataFrame(self.matched_signatures)
write_df = DataFrame(map(vars, self.matched_signatures))
if '.csv' not in self.output_path:
self.output_path += '.csv'
file_name = self.output_path
Expand Down
26 changes: 26 additions & 0 deletions test/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import tempfile
import unittest

from tell_me_your_secrets.__main__ import SignatureRecognizer
from tell_me_your_secrets.processor import SignatureMatch


class WriteResultsTest(unittest.TestCase):

def test_write_results_to_file_no_issues(self):
with tempfile.NamedTemporaryFile(suffix='.csv') as output_file:
signature_recognizer = SignatureRecognizer({}, "", False, 1, write_results=True,
output_path=output_file.name)
signature_recognizer.write_results_to_file()
self.assertEqual(b"", output_file.read())

def test_write_results_to_file_issues(self):
with tempfile.NamedTemporaryFile(suffix='.csv') as output_file:
signature_recognizer = SignatureRecognizer({}, "", False, 1, write_results=True,
output_path=output_file.name)
signature_recognizer.matched_signatures = [
SignatureMatch('Match', 'file', '/path/to/file')
]

signature_recognizer.write_results_to_file()
self.assertEqual(b',name,part,path\n0,Match,file,/path/to/file\n', output_file.read())

0 comments on commit 40ebe78

Please sign in to comment.