def test_show_version(self): output = StringIO() settings = Settings("127.0.0.1", 5000, output, Action.SHOW_VERSION) cli = CLI(settings, output) cli.show_version() expected = TextPrinter.ABOUT.format(version=__VERSION__, code_license=__LICENSE__, service=__SERVICE_NAME__) self.assertEqual(expected, output.getvalue())
def test_parsing_log_file_name_short_format(self): log_file = "my_log_file.log" settings = Settings.from_command_line(["-l", log_file]) self.assertEqual(log_file, settings.log_file)
def test_default_log_file_name(self): settings = Settings.from_command_line([]) self.assertEqual(Settings.DEFAULT_LOG_FILE, settings.log_file)
def test_parsing_port_number_short_format(self): port = "1234" settings = Settings.from_command_line(["-p", port]) self.assertEqual(int(port), settings.port)
def test_default_port_number(self): settings = Settings.from_command_line([]) self.assertEqual(int(Settings.DEFAULT_PORT), settings.port)
def test_default_hostname_short_format(self): hostname = "127.0.0.1" settings = Settings.from_command_line(["-n", hostname]) self.assertEquals(hostname, settings.hostname)
def test_default_hostname(self): settings = Settings.from_command_line([]) self.assertEquals(Settings.DEFAULT_HOSTNAME, settings.hostname)
def test_show_version_short_format(self): settings = Settings.from_command_line(["-v"]) self.assertEqual(Action.SHOW_VERSION, settings.action)
def test_default_action(self): settings = Settings.from_command_line([]) self.assertEqual(Action.START, settings.action)