-
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.
- Loading branch information
1 parent
df3b56e
commit c82e63d
Showing
7 changed files
with
144 additions
and
32 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
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 |
---|---|---|
@@ -1,13 +1,61 @@ | ||
{ | ||
"Audio": [".aif", ".cda", ".mid", ".mp3", ".ogg", ".wav", ".wma"], | ||
"Text": [".txt", ".doc", ".pdf", ".rtf"], | ||
"Video": [".mp4", ".avi", ".mkv", ".mov"], | ||
"Images": [".jpg", ".png", ".gif", ".bmp"], | ||
"Compressed": [".zip", ".rar", ".tar.gz"], | ||
"Disc": [".iso", ".dmg"], | ||
"Data": [".csv", ".xml", ".json"], | ||
"Executables": [".exe", ".bat", ".jar"], | ||
"Fonts": [".ttf", ".otf"], | ||
"Presentations": [".ppt", ".pptx"], | ||
"Other": [".bak", ".tmp", ".cfg"] | ||
"Audio": [ | ||
".aif", | ||
".cda", | ||
".mid", | ||
".mp3", | ||
".ogg", | ||
".wav", | ||
".wma" | ||
], | ||
"Text": [ | ||
".txt", | ||
".doc", | ||
".pdf", | ||
".rtf" | ||
], | ||
"Video": [ | ||
".mp4", | ||
".avi", | ||
".mkv", | ||
".mov" | ||
], | ||
"Images": [ | ||
".jpg", | ||
".png", | ||
".gif", | ||
".bmp" | ||
], | ||
"Compressed": [ | ||
".zip", | ||
".rar", | ||
".tar.gz" | ||
], | ||
"Disc": [ | ||
".iso", | ||
".dmg" | ||
], | ||
"Data": [ | ||
".csv", | ||
".xml", | ||
".json" | ||
], | ||
"Executables": [ | ||
".exe", | ||
".bat", | ||
".jar" | ||
], | ||
"Fonts": [ | ||
".ttf", | ||
".otf" | ||
], | ||
"Presentations": [ | ||
".ppt", | ||
".pptx" | ||
], | ||
"Other": [ | ||
".bak", | ||
".tmp", | ||
".cfg" | ||
] | ||
} |
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
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,35 @@ | ||
""" | ||
Test Class for JsonLoader module for loading config.json and file_extension.json files. | ||
This module contains the tests for the JsonLoader class, which provides methods to | ||
load json files in specified locations. | ||
""" | ||
import json | ||
import logging | ||
import unittest | ||
from unittest.mock import patch, mock_open | ||
from file_organizer.json_loader import JsonLoader | ||
|
||
class TestJsonLoader(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.loader = JsonLoader(config_file="", extensions_file_config="") | ||
|
||
@patch("builtins.open", new_callable=mock_open, read_data='{"name": "vera"}') | ||
def test_load_json_success(self, mock_file): | ||
data = self.loader.load_json("valid_config.json") | ||
self.assertIsNotNone(data) | ||
self.assertEqual(data["name"], "vera") | ||
mock_file.assert_called_once_with("valid_config.json", "r", encoding="utf-8") | ||
|
||
def test_load_json_file_not_found(self): | ||
with self.assertRaises(FileNotFoundError): | ||
self.loader.load_json("not_found.json") | ||
|
||
@patch("builtins.open", new_callable=mock_open, read_data='{"invalid":}') | ||
def test_load_json_invalid(self, mock_open): | ||
with self.assertRaises(json.JSONDecodeError): | ||
self.loader.load_json("invalid.json") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |