def __init__(self): self.optional_argument = list() AppContainer.secret = SecretParser() AppContainer.config = ConfigParser() AppContainer.secret.get_zebra = MagicMock(return_value={'url': 'xx'}) AppContainer.secret.get_jira = MagicMock(return_value={'url': 'xx'}) AppContainer.config.get_sprint = MagicMock( return_value=self.get_sprint())
def testParsingPlannedSection(self): parser = ConfigParser() config = [1,2,0,3] result = parser.parse_planned(config, date(2005, 1, 5), date(2005, 1, 10)) self.assertEquals({'2005-01-05': 1, '2005-01-06': 2, '2005-01-07': 0, '2005-01-10': 3}, result) with self.assertRaises(SyntaxError): parser.parse_planned([1,2,3], date(2005, 1, 5), date(2005, 1, 10)) with self.assertRaises(SyntaxError): parser.parse_planned([1,2,3,4,5], date(2005, 1, 5), date(2005, 1, 10))
def testParsingPlannedSection(self): parser = ConfigParser() config = [1, 2, 0, 3] result = parser.parse_planned(config, date(2005, 1, 5), date(2005, 1, 10)) self.assertEquals( { '2005-01-05': 1, '2005-01-06': 2, '2005-01-07': 0, '2005-01-10': 3 }, result) with self.assertRaises(SyntaxError): parser.parse_planned([1, 2, 3], date(2005, 1, 5), date(2005, 1, 10)) with self.assertRaises(SyntaxError): parser.parse_planned([1, 2, 3, 4, 5], date(2005, 1, 5), date(2005, 1, 10))
def run(self, args): # Open the config file FileHelper.open_for_edit(AppContainer.SETTINGS_PATH) # Validate it print "Start validation" parser = ConfigParser() parser.load_config(AppContainer.SETTINGS_PATH) sprints = self.config.get_sprints() error = False if len(sprints) == 0: print 'No sprints defined' error = True else: for name, data in sprints.items(): try: parser.parse_sprint(name, data) except Exception as e: print "Error in sprint [{}] definition: ".format(name), e error = True if error is False: print 'Well done, no error detected!'
def __init__(self): usage = """%(prog)s command [options] available commands: sprint-burnup\t\tPrints a burn up chart for a given sprint until an optional date (defaults to yesterday) test-install\t\tTest the installation get-user-id\t\tRetrieve a Zebra user id from his/her last name ls \t\t\tList all sprints defined in config edit \t\t\tOpen the config in edit mode jira-config-helper\tRetrieve some useful information about a Jira project and sprint from a story id (ie. XX-12) add-sprint\t\tAdds a sprint to your config file check-hours\t\tRetrieve all Zebra hours for a date/user(s). User is optional and can be multiple. Date is optional defaults to yesterday. If 2 dates are specified then min = start date, max = end date get-last-zebra-day\tRetrieve the last Zebra day that contains a commit for this project result-per-story\t\tPrint the actual time used per story dump-sprint-config\t\tOutput your config for a specific sprint""" SETTINGS_PATH = os.path.expanduser('~/.lst.yml') SECRET_PATH = os.path.expanduser('~/.lst-secret.yml') available_actions = { 'sprint-burnup': SprintBurnUpCommand, 'test-install': TestInstallCommand, 'get-user-id': RetrieveUserIdCommand, 'ls': ListCommand, 'edit': EditCommand, 'jira-config-helper': RetrieveJiraInformationForConfigCommand, 'add-sprint': AddSprintCommand, 'check-hours': CheckHoursCommand, 'get-last-zebra-day': GetLastZebraDayCommand, 'result-per-story': ResultPerStoryCommand, 'dump-sprint-config': DumpSprintConfigCommand, } # define arguments and options parser = argparse.ArgumentParser( prog='lst', formatter_class=argparse.RawDescriptionHelpFormatter, usage=usage) # add version argument parser.add_argument('-v', '--version', action='version', version=__version__) # add arguments for all commands subparsers = parser.add_subparsers(dest='command') for name, command in available_actions.items(): action = command() # add specific args subparser = action.add_command_arguments(subparsers) # add common args action.add_common_arguments(subparser) # read command line arguments args = parser.parse_args() AppContainer.SETTINGS_PATH = SETTINGS_PATH AppContainer.SECRET_PATH = SECRET_PATH # read usernames and passwords for jira/zebra secret = SecretParser() secret.parse(SECRET_PATH) # create globally accessible app container AppContainer.secret = secret AppContainer.user_args = args AppContainer.dev_mode = args.dev_mode # read config print 'Reading config' config = ConfigParser() config.load_config(SETTINGS_PATH) AppContainer.config = config if args.command not in available_actions: raise NotFoundError("Command '%s' does not exist. See lst -h" % (args.command)) action = available_actions[args.command]() action.run(args)
def __init__(self): usage = """%(prog)s command [options] available commands: sprint-burnup\t\tPrints a burn up chart for a given sprint until an optional date (defaults to yesterday) test-install\t\tTest the installation get-user-id\t\tRetrieve a Zebra user id from his/her last name ls \t\t\tList all sprints defined in config edit \t\t\tOpen the config in edit mode jira-config-helper\tRetrieve some useful information about a Jira project and sprint from a story id (ie. XX-12) add-sprint\t\tAdds a sprint to your config file check-hours\t\tRetrieve all Zebra hours for a date/user(s). User is optional and can be multiple. Date is optional defaults to yesterday. If 2 dates are specified then min = start date, max = end date get-last-zebra-day\tRetrieve the last Zebra day that contains a commit for this project result-per-story\t\tPrint the actual time used per story dump-sprint-config\t\tOutput your config for a specific sprint""" SETTINGS_PATH = os.path.expanduser('~/.lst.yml') SECRET_PATH = os.path.expanduser('~/.lst-secret.yml') available_actions = { 'sprint-burnup': SprintBurnUpCommand, 'test-install': TestInstallCommand, 'get-user-id': RetrieveUserIdCommand, 'ls': ListCommand, 'edit': EditCommand, 'jira-config-helper': RetrieveJiraInformationForConfigCommand, 'add-sprint': AddSprintCommand, 'check-hours': CheckHoursCommand, 'get-last-zebra-day': GetLastZebraDayCommand, 'result-per-story': ResultPerStoryCommand, 'dump-sprint-config': DumpSprintConfigCommand, } # define arguments and options parser = argparse.ArgumentParser( prog='lst', formatter_class=argparse.RawDescriptionHelpFormatter, usage=usage ) # add version argument parser.add_argument('-v', '--version', action='version', version=__version__) # add arguments for all commands subparsers = parser.add_subparsers(dest='command') for name, command in available_actions.items(): action = command() # add specific args subparser = action.add_command_arguments(subparsers) # add common args action.add_common_arguments(subparser) # read command line arguments args = parser.parse_args() AppContainer.SETTINGS_PATH = SETTINGS_PATH AppContainer.SECRET_PATH = SECRET_PATH # read usernames and passwords for jira/zebra secret = SecretParser() secret.parse(SECRET_PATH) # create globally accessible app container AppContainer.secret = secret AppContainer.user_args = args AppContainer.dev_mode = args.dev_mode # read config print 'Reading config' config = ConfigParser() config.load_config(SETTINGS_PATH) AppContainer.config = config if args.command not in available_actions: raise NotFoundError("Command '%s' does not exist. See lst -h" % (args.command)) action = available_actions[args.command]() action.run(args)