-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: impelemented test project structure for #40
- Loading branch information
Showing
8 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
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 @@ | ||
import os | ||
import unittest | ||
from configparser import ConfigParser | ||
|
||
class TestConfig(unittest.TestCase): | ||
def setUp(self): | ||
""" Setup is the first method run in the test.""" | ||
self.path = os.path.join('Config/logger.ini') | ||
|
||
if not os.path.isdir('Logs'): | ||
os.mkdir('Logs') | ||
if not os.path.exists(os.path.join('Logs', 'traceback.log')): | ||
with open(os.path.join('Logs', 'traceback.log'), 'w') as fp: | ||
fp.write("Created traceback.log as part of tests.") | ||
fp.close() | ||
|
||
def test_config_exists(self): | ||
self.assertTrue(self.path) | ||
|
||
def test_config_is_valid(self): | ||
parser = ConfigParser() | ||
if self.test_config_exists: | ||
parser.read(self.path) | ||
|
||
# Check if the required sections are present in the config | ||
self.assertIn('formatters', parser.sections()) | ||
self.assertIn('handler_console', parser.sections()) | ||
|
||
# Check if the required keys are present in the sections | ||
self.assertIn('keys', parser['formatters']) | ||
self.assertIn('level', parser['handler_console']) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Empty file.
Empty file.
Empty file.
Empty file.