def test_send(self):
        runner = MagicMock()

        mattermost = MattermostNotifier('http://dummy', runner)
        mattermost.append('test')
        mattermost.send()

        runner.send.assert_called_with('http://dummy', {'text': 'test', 'username': '******'})
Exemple #2
0
    print('Synchronizer v{}\n============================'.format(
        version.VERSION))

    if args.version:
        sys.exit(0)

    config = Config.fromFile()

    print('Found api key pairs: {}'.format(len(config.entries)))
    mattermost = MattermostNotifier(
        config.mattermost, RequestsRunner(),
        args.simulation) if config.mattermost != None else None

    for apiKeys in config.entries:
        toggl = TogglHelper(config.toggl, apiKeys.toggl)
        redmine = RedmineHelper(config.redmine, apiKeys.redmine,
                                args.simulation)

        if mattermost != None:
            mattermost.append('Toggl2Redmine v{} for {}'.format(
                version.VERSION, apiKeys.label))
            mattermost.append('---')
            mattermost.append('')

        sync = Synchronizer(config, redmine, toggl, mattermost)
        sync.start(args.days)

    if mattermost != None:
        mattermost.send()