-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for filereader and filewriter (#6)
* initial check-in of working version. * add file containing dependencies to install * first draft * added more lint rules. cleaned up table format. * updated lint rules * Removed references from the bottom of the page * Move process impl into the base class FileProcessor. * use file_extension as key to look up the right FileWriter class * add newline * add command line arg processing * corrected file extensions lookup table * move FileReader responsibility out of the FileProcessor * expose FileReader and message linter * modify FileProcessor to accept FileReader and FileWriter * use updated FileProcessor * add more command line usages * rename to message_lint (from str_res_lint) * update README to reflect the renaming to message_lint (from str_res_lint) * remove static method (build_output_folder) from FileWriter * add test files * Create .gitignore * don't include __pycache__ * reorganize table * change --dest option to --output_folder * clean up table. remove need for --file option. rename --dest option to `output_folder` * correct to NullFileReader * fix indentation issue * add unit tests for filereader and filewriter. * remove commented code
- Loading branch information
Showing
4 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,6 @@ def read(self) -> dict: | |
content[message_id] = { | ||
"message": message | ||
} | ||
|
||
return content | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
import filereader as fr | ||
|
||
|
||
class FileReaderTest(unittest.TestCase): | ||
def test_json_filereader(self): | ||
filename = "../test_files/test.json" | ||
reader = fr.FileReader.get(filename) | ||
self.assertEqual(type(reader), type(fr.JsonFileReader(filename))) | ||
|
||
def test_null_filereader(self): | ||
filename = "../test_files/test.j" | ||
reader = fr.FileReader.get(filename) | ||
self.assertEqual(type(reader), type(fr.NullFileReader(filename))) | ||
|
||
def test_properties_filereader(self): | ||
filename = "../test_files/test.properties" | ||
reader = fr.FileReader.get(filename) | ||
self.assertEqual(type(reader), type(fr.PropertiesFileReader(filename))) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
import filewriter as fw | ||
|
||
|
||
class FileWriterTest(unittest.TestCase): | ||
def test_json_filewriter(self): | ||
filename = "../test_files/test.json" | ||
reader = fw.FileWriter.get(filename) | ||
self.assertEqual(type(reader), type(fw.JsonFileWriter(filename))) | ||
|
||
def test_null_filewriter(self): | ||
filename = "../test_files/test.j" | ||
reader = fw.FileWriter.get(filename) | ||
self.assertEqual(type(reader), type(fw.BadFileWriter(filename))) | ||
|
||
def test_properties_filewriter(self): | ||
filename = "../test_files/test.properties" | ||
reader = fw.FileWriter.get(filename) | ||
self.assertEqual(type(reader), type(fw.PropertiesFileWriter(filename))) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |