def test_it_returns_version_command(self): args = ArgsParserBuilder.build(self.cmd('-v')) self.assertIsInstance( Cli.command(ArgsParserBuilder.build(self.cmd('-v'))), VersionCommand) self.assertIsInstance( Cli.command(ArgsParserBuilder.build(self.cmd('--version'))), VersionCommand)
def run(): print("Croutera...") args = ArgsParserBuilder.build(sys.argv[1:]) if not Cli.validate(args): show_help() return cmd = Cli.command(args) if cmd.valid() and cmd.execute(): print('Command executed.') else: print('Command was not executed.')
def test_it_returns_at_first_authorize_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build(self.cmd("-restart manufacturer-model1 usr pas")) command = Cli.command(args) self.assertTrue(command.commands[0], AuthorizeCommand)
def test_it_returns_at_end_show_wifi_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build( self.cmd('-wifi-pass manufacturer-model1 usr pas')) command = Cli.command(args) self.assertIsInstance(command.commands[1], ShowWifiPassCommand)
def test_it_returns_at_end_restart_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build( self.cmd('-restart manufacturer-model1 usr pas')) command = Cli.command(args) self.assertTrue(command.commands[1], RestartCommand)
def test_it_returns_chain_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build( self.cmd('-restart manufacturer-model1 usr pas')) command = Cli.command(args) self.assertIsInstance(command, ChainCommand)
def test_it_returns_at_end_show_wifi_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build(self.cmd("-wifi-pass manufacturer-model1 usr pas")) command = Cli.command(args) self.assertIsInstance(command.commands[1], ShowWifiPassCommand)
def test_it_returns_chain_command(self, Routers): setup_mocked_routers(Routers) args = ArgsParserBuilder.build(self.cmd("-restart manufacturer-model1 usr pas")) command = Cli.command(args) self.assertIsInstance(command, ChainCommand)
def test_it_returns_version_command(self): args = ArgsParserBuilder.build(self.cmd("-v")) self.assertIsInstance(Cli.command(ArgsParserBuilder.build(self.cmd("-v"))), VersionCommand) self.assertIsInstance(Cli.command(ArgsParserBuilder.build(self.cmd("--version"))), VersionCommand)
def test_it_returns_model_list_command(self): args = ArgsParserBuilder.build(self.cmd("-list-models")) command = Cli.command(args) self.assertTrue(command, ModelListCommand)
def test_it_returns_model_list_command(self): args = ArgsParserBuilder.build(self.cmd('-list-models')) command = Cli.command(args) self.assertTrue(command, ModelListCommand)