def test__prepare_results_for_output_simple__shortend_paths(self): # Arrange base = os.path.join("C:/", "My", "Path") sr1 = SearchResult(os.path.join(base, "MyFile.txt"), "term1", 10) sr2 = SearchResult(os.path.join(base, "MyFile.txt"), "term1", 20) sr3 = SearchResult(os.path.join(base, "OtherFile.txt"), "term1", 11) sr4 = SearchResult(os.path.join(base, "sub", "MyFile.txt"), "term1", 12) sr5 = SearchResult(os.path.join(base, "sub", "OtherFile.txt"), "term2", 13) sr6 = SearchResult(os.path.join(base, "sub2", "MyFile.txt"), "term2", 14) sr7 = SearchResult(os.path.join(base, "sub2", "OtherFile.txt"), "term3", 15) sr8 = SearchResult(os.path.join(base, "sub2", "OtherFile.txt"), "term3", 25) input_res = [sr1, sr2, sr3, sr4, sr5, sr6, sr7, sr8] fcs = FileContentSearch(['term', '-d', base]) # Act result = fcs._prepare_results_for_output_simple(input_res) # Assert self.assertIn("MyFile.txt", result) self.assertIn("OtherFile.txt", result) self.assertIn(os.path.join("sub", "MyFile.txt"), result) self.assertIn(os.path.join("sub", "OtherFile.txt"), result) self.assertIn(os.path.join("sub2", "MyFile.txt"), result) self.assertIn(os.path.join("sub2", "OtherFile.txt"), result)
#! /usr/bin/env python # -*- coding: utf-8 -*- from src.file_content_search import FileContentSearch import sys __author__ = 'Stephan Tischer' __date__ = '2018-07-11' __version__ = '0.1.0' if __name__ == "__main__": fcs = FileContentSearch(sys.argv) print(fcs.search())