def test_invoked(self, patched_ScriptInvocation): retval = ScriptCommand(self.provider, self.config).invoked(self.ns) patched_ScriptInvocation.assert_called_once_with( self.provider, self.config, self.ns.job_name) self.assertEqual( retval, patched_ScriptInvocation( self.provider, self.config, self.ns.job_name).run.return_value)
def register_parser(self, subparsers): parser = subparsers.add_parser( "dev", help="development commands") subdev = parser.add_subparsers() ScriptCommand(self.provider, self.config).register_parser(subdev) SpecialCommand(self.provider).register_parser(subdev) AnalyzeCommand(self.provider).register_parser(subdev) ParseCommand().register_parser(subdev) CrashCommand().register_parser(subdev) LogTestCommand().register_parser(subdev)
def test_register_parser(self): ScriptCommand(self.provider_list, self.config).register_parser(self.subparsers) with TestIO() as io: self.parser.print_help() self.assertIn("script run a command from a job", io.stdout) with TestIO() as io: with self.assertRaises(SystemExit): self.parser.parse_args(['script', '--help']) self.assertEqual( io.stdout, cleandoc(""" usage: test script [-h] JOB-ID positional arguments: JOB-ID Id of the job to run optional arguments: -h, --help show this help message and exit """) + "\n")
def test_init(self): script_cmd = ScriptCommand(self.provider, self.config) self.assertIs(script_cmd.provider, self.provider) self.assertIs(script_cmd.config, self.config)