def test_parse_custom_port_and_host(self): command = Command() options = {'liveport': 8888, 'addrport': '0.0.0.0:8000'} command._parse_options(**options) self.assertEqual(command.liveport, 8888) self.assertEqual(command.livehost, '0.0.0.0')
def test_parse_default_options(self): command = Command() options = {'liveport': None, 'addrport': ''} command._parse_options(**options) self.assertEqual(command.liveport, 9001) self.assertEqual(command.livehost, 'localhost')
class OptionsParserTestcase(unittest.TestCase): def setUp(self): self.command = Command() def tearDown(self): settings.DJANGO_LIVESYNC = dict() def test_parse_default_options(self): options = {'liveport': None, 'addrport': ''} self.command._parse_options(**options) self.assertEqual(self.command.liveport, 9001) self.assertEqual(self.command.livehost, 'localhost') def test_parse_custom_port_and_host(self): options = {'liveport': 8888, 'addrport': '0.0.0.0:8000'} self.command._parse_options(**options) self.assertEqual(self.command.liveport, 8888) self.assertEqual(self.command.livehost, '0.0.0.0') def test_parse_invalid_port_raises_command_error(self): options = {'liveport': 'abc', 'addrport': ''} with self.assertRaises(CommandError): self.command._parse_options(**options)
def test_customize_event_handler(self): command = Command() command._start_watchdog() handler, = command.file_watcher.handlers self.assertIsInstance(handler, MockEventHandler)
def test_default_event_handler(self): command = Command() command._start_watchdog() handler, = command.file_watcher.handlers self.assertIsInstance(handler, LiveReloadRequestHandler)
def test_parse_invalid_port_raises_command_error(self): command = Command() options = {'liveport': 'abc', 'addrport': ''} with self.assertRaises(CommandError): command._parse_options(**options)
def setUp(self): self.command = Command()