def create_cmd(self): current_cmd = CurrentCMD_B(self.output) return current_cmd
def create_cmd(self): return CurrentCMD_B(self.runner_message)
def setUp(self): self.test_cmd = CurrentCMD_B("Runner Message")
class TestCurrentCmdB(unittest.TestCase): def setUp(self): self.test_cmd = CurrentCMD_B("Runner Message") def test_create_uml_sets_command(self): self.test_cmd.do_create_uml("args") assert self.test_cmd.current_command == "do_create_uml" def test_create_uml_returns_true(self): assert self.test_cmd.do_create_uml("args") is True def test_deserialize_sets_command(self): self.test_cmd.do_deserialize("args") assert self.test_cmd.current_command == "do_deserialize" def test_deserialize_returns_true(self): assert self.test_cmd.do_deserialize("args") is True def test_info_prints(self): test_str = "by Azez Nassar & Ethan Bray in Python3" stdout = sys.stdout s = StringIO() sys.stdout = s self.test_cmd.do_info(" ") sys.stdout = stdout s.seek(0) assert test_str in s.read() def test_quit_prints_to_terminal(self): test_str = "Leaving System" stdout = sys.stdout s = StringIO() sys.stdout = s self.test_cmd.do_quit(" ") sys.stdout = stdout s.seek(0) assert test_str in s.read() def test_quit_sets_command(self): self.test_cmd.do_quit("args") assert self.test_cmd.current_command == "do_quit" def test_quit_returns_true(self): assert self.test_cmd.do_quit("args") is True def test_switch_cmd_prints_to_terminal(self): test_str = "Swapping to Azez's Command Line" stdout = sys.stdout s = StringIO() sys.stdout = s self.test_cmd.do_switch_cmd(" ") sys.stdout = stdout s.seek(0) assert test_str in s.read() def test_switch_cmd_sets_command(self): self.test_cmd.do_switch_cmd("args") assert self.test_cmd.current_command == "do_switch_cmd" def test_switch_cmd_returns_true(self): assert self.test_cmd.do_switch_cmd("args") is True def test_help_prints_to_terminal(self): test_str = "description: Prints deserialized cla" stdout = sys.stdout s = StringIO() sys.stdout = s self.test_cmd.do_help(" ") sys.stdout = stdout s.seek(0) assert test_str in s.read() def test_unrecognized_command(self): test_str = "Sorry, the command: blah was not recognized," stdout = sys.stdout s = StringIO() sys.stdout = s self.test_cmd.default(test_str) sys.stdout = stdout s.seek(0) assert "blah" in s.read()
def setUp(self): self.cmd_b = CurrentCMD_B("Ethan")
class CmdBTests(unittest.TestCase): def setUp(self): self.cmd_b = CurrentCMD_B("Ethan") def test_cmd_b_help(self): import sys from io import StringIO out = StringIO() sys.stdout = out self.cmd_b.do_help(None) output = out.getvalue().strip() assert 'Deletes the serialized file(s) after printing data' in output def test_cmd_b_create_uml(self): self.cmd_b.do_create_uml(None) self.assertEqual(self.cmd_b.current_command, "do_create_uml", "create_uml test failed") self.assertTrue(self.cmd_b.do_create_uml(None), "create_uml test failed") def test_cmd_b_deserialize(self): self.cmd_b.do_deserialize(None) self.assertEqual(self.cmd_b.current_command, "do_deserialize", "deserialize test failed") self.assertTrue(self.cmd_b.do_create_uml(None), "deserialize test failed") def test_cmd_b_info(self): out = StringIO() sys.stdout = out self.cmd_b.do_info(None) output = out.getvalue().strip() assert 'The software was developed by Azez Nassar & Ethan Bray in Python3' in output def test_cmd_b_switch_cmd(self): out = StringIO() sys.stdout = out self.cmd_b.do_switch_cmd(None) output = out.getvalue().strip() assert "Swapping to Azez's Command Line" in output self.cmd_b.do_switch_cmd(None) self.assertEqual(self.cmd_b.current_command, "do_switch_cmd", "switch_cmd test failed") self.assertTrue(self.cmd_b.do_switch_cmd(None), "switch_cmd test failed") def test_cmd_b_quit(self): out = StringIO() sys.stdout = out self.cmd_b.do_quit(None) output = out.getvalue().strip() assert "Leaving System" in output self.cmd_b.do_quit(None) self.assertEqual(self.cmd_b.current_command, "do_quit", "quit test failed") self.assertTrue(self.cmd_b.do_quit(None), "quit test failed") def test_cmd_b_default(self): out = StringIO() sys.stdout = out self.cmd_b.default(None) output = out.getvalue().strip() assert "Sorry, the command:" in output
def __init__(self): self.cmd_a = CurrentCMD_A("Starting Output") self.cmd_b = CurrentCMD_B("Starting Output")