def test_propper_config_has_values(self):
        config = Config()

        with NamedTemporaryFile() as configfile:
            configfile.write(
                "\n".join(
                    (
                        "[watchlist]",
                        "github-login = foo",
                        "github-oauth-token = bar",
                        "watchlist =",
                        "  watching: foo/*",
                        "  watching: bar/bar",
                        "  not-watching: bar/*",
                    )
                )
            )
            configfile.file.flush()
            config.load(configfile.name)

        self.assertEquals("foo", config.github_login, "Wrong github login")
        self.assertEquals("bar", config.github_oauth_token, "Wrong github token")

        self.assertEquals(
            [("watching", "foo/*"), ("watching", "bar/bar"), ("not-watching", "bar/*")],
            config.watchlist,
            "Unexpected watchlist in config",
        )
    def test_empty_lines_and_comments_in_watchlist(self):
        config = Config()

        with NamedTemporaryFile() as configfile:
            configfile.write(
                "\n".join(
                    (
                        "[watchlist]",
                        "github-login = foo",
                        "github-oauth-token = bar",
                        "watchlist =",
                        "  watching: foo/*",
                        "",
                        "  watching: bar/*",
                        "# comment",
                        "  watching: baz/*",
                        "",
                    )
                )
            )
            configfile.file.flush()
            config.load(configfile.name)

        self.assertEquals(
            [("watching", "foo/*"), ("watching", "bar/*"), ("watching", "baz/*")],
            config.watchlist,
            "Unexpected watchlist in config",
        )
Exemple #3
0
def update_command():
    parser = argparse.ArgumentParser(description='Setup github watchlist.')
    add_config_argument_to_argparser(parser)
    add_log_argument_to_argparse(parser)

    parser.add_argument(
        '-C', '--confirmed', action='store_true',
        dest='confirmed',
        help='Update the subscriptions without user confirmation.'
        ' This is useful when running as cronjob.')

    parser.add_argument(
        '-D', '--debug', action='store_true',
        dest='debug',
        help='Start post mortem debugger on python exceptions.')

    parser.add_argument(
        '-v', '--verbose', action='store_true',
        dest='verbose',
        help='Print more verbose informations about whats happening.')

    args = parser.parse_args()
    if args.debug:
        sys.excepthook = post_mortem_debugging_hook
    if args.verbose:
        os.environ['VERBOSE'] = '1'
    setup_logging(args)

    config = Config()
    config.load(args.configfile)

    UpdateCommand(config)(confirmed=args.confirmed)
    def test_empty_lines_and_comments_in_watchlist(self):
        config = Config()

        with NamedTemporaryFile() as configfile:
            configfile.write('\n'.join(
                ('[watchlist]', 'github-login = foo',
                 'github-oauth-token = bar', 'watchlist =',
                 '  watching: foo/*', '', '  watching: bar/*', '# comment',
                 '  watching: baz/*', '')))
            configfile.file.flush()
            config.load(configfile.name)

        self.assertEquals([('watching', 'foo/*'), ('watching', 'bar/*'),
                           ('watching', 'baz/*')], config.watchlist,
                          'Unexpected watchlist in config')
Exemple #5
0
def update_command():
    parser = argparse.ArgumentParser(description='Setup github watchlist.')
    add_config_argument_to_argparser(parser)
    add_log_argument_to_argparse(parser)

    parser.add_argument(
        '-C', '--confirmed', action='store_true',
        dest='confirmed',
        help='Update the subscriptions without user confirmation.'
        ' This is useful when running as cronjob.')

    args = parser.parse_args()
    setup_logging(args)

    config = Config()
    config.load(args.configfile)

    UpdateCommand(config)(confirmed=args.confirmed)
    def test_propper_config_has_values(self):
        config = Config()

        with NamedTemporaryFile() as configfile:
            configfile.write('\n'.join(
                ('[watchlist]', 'github-login = foo',
                 'github-oauth-token = bar', 'watchlist =',
                 '  watching: foo/*', '  watching: bar/bar',
                 '  not-watching: bar/*')))
            configfile.file.flush()
            config.load(configfile.name)

        self.assertEquals('foo', config.github_login, 'Wrong github login')
        self.assertEquals('bar', config.github_oauth_token,
                          'Wrong github token')

        self.assertEquals([('watching', 'foo/*'), ('watching', 'bar/bar'),
                           ('not-watching', 'bar/*')], config.watchlist,
                          'Unexpected watchlist in config')