Coverage for tests/command/builder/test_command_factory.py: 100%
17 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-01-30 18:57 -0500
« prev ^ index » next coverage.py v7.1.0, created at 2023-01-30 18:57 -0500
1"""Unit test file for command.builder.command_factory.py."""
2from src.probable_fiesta.command.builder import command_factory
3from src.probable_fiesta.logger.logging_config import set_logger
5from logging import DEBUG
6from unittest import TestCase
8# Create a logger
9LOG = set_logger("test_command_factory", DEBUG)
12class TestCommandBuilderCommandFactory(TestCase):
14 def setUp(self):
15 self.command = command_factory.CommandFactory()
17 # Class is only a factory no need to test init
18 #def test_init(self):
19 #LOG.info("Test init")
20 #self.command = command_factory.CommandFactory()
21 #self.assertEqual(self.command.name, None)
22 #self.assertEqual(self.command.function, None)
23 #self.assertEqual(self.command.args, None)
24 ## test _str__
25 #LOG.debug(str(self.command))
26 #self.assertEqual(str(self.command), "Command: {'name': None, 'function': None, 'args': None}")
28 def test_new_command(self):
29 LOG.info("Test new command")
30 function = lambda: "Hello World!"
31 self.command = command_factory.CommandFactory().new_command("test", function, "--version")
32 self.assertEqual(self.command.name, "test")
33 self.assertEqual(self.command.function, function)
34 self.assertEqual(self.command.args, ('--version',))
35 # test _str__
36 LOG.debug(str(self.command))
37 self.assertEqual(str(self.command), "Command: {'name': 'test', "+f"'function': {function},"+" 'args': ('--version',)}")