# limepkg-sendsms/limepkg_sendsms/command_handlers/sendsms_test.pyfromtypingimportListimportpytestfromlime_application.applicationimportLimeApplicationfromlimepkg_server_commands.commandsimportCommand,CommandDispatcherdeftest_sendsms(execute_commands):commands=[Command("send-sms",{"to":"555-not-a-number","text":"You have to report time in Sublime!"},),Command("send-sms",{"to":"+46123456789","text":"You have to report time in Sublime!"},),]batchresult=execute_commands(commands)cr=batchresult["commandresults"]some_failed=any([notcommand.successfulforcommandincr])assertsome_failed,"Batch succeeded"assertbatchresult["errors"][0]=="Invalid phonenumber: 555-not-a-number"@pytest.fixturedefexecute_commands(limeapp:LimeApplication):defexecute_batch(commands:List[Command]):dispatcher=CommandDispatcher.default()ctx=dispatcher.create_context(limeapp)commandresults=dispatcher.execute_batch(ctx,commands)return{"successful":all([commandresult.successfulforcommandresultincommandresults]),"commandresults":commandresults,"errors":[r.error.messageforrincommandresultsifr.errorisnotNone],}returnexecute_batch