Example #1
0
def slack_bot():
    store_install = TeamiclinkInstallStore(data_source_name=DB_USER_REGULAR)
    store_install.create_bot(
        team_id=TEAM_ID2,
        bot_id="any_bot_id",
        bot_token="any_bot_token",
        bot_user_id="any_bot_user_id",
        installed_at=datetime.today(),
    )
    yield store_install.create_bot(
        team_id=TEAM_ID1,
        bot_id="any_bot_id",
        bot_token="any_bot_token",
        bot_user_id="any_bot_user_id",
        installed_at=datetime.today(),
    )
Example #2
0
def slack_bot(install_store: TeamiclinkInstallStore):
    yield install_store.create_bot(
        team_id=TEAM_ID,
        bot_token=BOT_TOKEN,
        bot_id=BOT_ID,
        bot_user_id=BOT_USER_ID,
        installed_at=INSTALLED_AT,
    )
Example #3
0
def test_it_creates_slack_bot(install_store: TeamiclinkInstallStore):
    # when
    result = install_store.create_bot(
        team_id=TEAM_ID,
        bot_token=BOT_TOKEN,
        bot_id=BOT_ID,
        bot_user_id=BOT_USER_ID,
        installed_at=INSTALLED_AT,
    )
    # then
    assert result.team_id == TEAM_ID
    assert result.id is not None
    assert result.bot_id == BOT_ID
    assert result.bot_user_id == BOT_USER_ID
    assert result.installed_at == INSTALLED_AT
    assert result.bot_token == BOT_TOKEN
Example #4
0
def test_it_updates_fields_when_creating_existing_bot(
    install_store: TeamiclinkInstallStore, slack_bot: TeamiclinkBot, mocker
):
    # given
    updater = mocker.patch.object(install_store, "update_bot")
    updater.return_value = slack_bot

    # when
    result = install_store.create_bot(
        team_id=slack_bot.team_id,
        bot_token=slack_bot.bot_token,
        bot_id=slack_bot.bot_id,
        bot_user_id=slack_bot.bot_user_id,
        installed_at=slack_bot.installed_at,
    )

    # then
    assert result == updater.return_value
    updater.assert_called_once_with(
        team_id=slack_bot.team_id,
        bot_token=slack_bot.bot_token,
        bot_id=slack_bot.bot_id,
        bot_user_id=slack_bot.bot_user_id,
    )