示例#1
0
    def test_send(self):
        runner = MagicMock()

        mattermost = MattermostNotifier(runner)
        mattermost.append("test")
        mattermost.send()

        runner.send.assert_called_with("test")
示例#2
0
    if config.mattermost:
        runner = RequestsRunner.fromConfig(config.mattermost)
        mattermost = MattermostNotifier(runner, args.simulation)

    for config_entry in config.entries:
        print("Synchronization for {} ...".format(config_entry.label))
        print("---")
        toggl = TogglHelper(config.toggl, config_entry)
        api_helper = ApiHelperFactory(config_entry).create()
        if not api_helper:
            print(
                "Can't interpret config to destination API - entry: {}".format(
                    config_entry.label))
            continue

        if mattermost != None:
            mattermost.append("TogglSync v{} for {}".format(
                version.VERSION, config_entry.label))
            mattermost.append("---")
            mattermost.append("")

        sync = Synchronizer(config,
                            api_helper,
                            toggl,
                            mattermost,
                            raise_errors=args.errors)
        sync.start(args.days)

    if mattermost != None:
        mattermost.send()