예제 #1
0
 def testExtractData(self):
     """extract_data should not raise any error"""
     secret = SecretParser()
     config = {'zebra': 'xx', 'jira': 'xx', 'output_dir': 'xx'}
     secret.extract_data(config)
     self.assertTrue(secret.zebra_data is not None)
     self.assertTrue(secret.jira_data is not None)
     self.assertTrue(secret.output_dir is not None)
예제 #2
0
 def testExtractData(self):
     """extract_data should not raise any error"""
     secret = SecretParser()
     config = {'zebra': 'xx', 'jira': 'xx', 'output_dir': 'xx'}
     secret.extract_data(config)
     self.assertTrue(secret.zebra_data is not None)
     self.assertTrue(secret.jira_data is not None)
     self.assertTrue(secret.output_dir is not None)
예제 #3
0
    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())
예제 #4
0
    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)
예제 #5
0
파일: __init__.py 프로젝트: jeanmonod/lst
    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)
예제 #6
0
 def testFileNotFound(self):
     """a FileNotFoundError should be raised if .lst-secret.yml is not found"""
     secret = SecretParser()
     self.assertRaises(FileNotFoundError, secret.parse, 'xx')
예제 #7
0
 def testOutputDirEndsWithSlash(self):
     """get_output_dir should end with a slash"""
     secret = SecretParser()
     config = {'zebra': 'xx', 'jira': 'xx', 'output_dir': 'xx'}
     secret.extract_data(config)
     self.assertEquals('xx/', secret.get_output_dir())
예제 #8
0
 def testSyntaxErrorOnExtractData(self):
     """a SyntaxError should be raised if .lst-secret.yml structure is not ok"""
     secret = SecretParser()
     config = {'zebra': 'xx', 'jira': 'xx'}
     self.assertRaises(SyntaxError, secret.extract_data, config)
예제 #9
0
 def testOutputDirEndsWithSlash(self):
     """get_output_dir should end with a slash"""
     secret = SecretParser()
     config = {'zebra': 'xx', 'jira': 'xx', 'output_dir': 'xx'}
     secret.extract_data(config)
     self.assertEquals('xx/', secret.get_output_dir())