예제 #1
0
def test_fetch_github_summary_post_to_slack_with_no_users(
        session, factory, t_minus_one_day, patched_slack,
        patched_github_user_events):
    # Arrange
    channel = "general"
    boundary_dt = t_minus_one_day
    github_summary_config = factory.GitHubSummaryConfiguration(channel=channel)
    slack_installation = github_summary_config.slack_installation
    channel_info = Channel(name="general", members=["user1", "user2"])
    slack = patched_slack(channel_info=channel_info)
    patched_github_user_events(messages=["a", "b"])

    # Act
    fetch_github_summary_post_to_slack(installation_id=slack_installation.id,
                                       boundary_dt=boundary_dt)

    # Assert
    slack_adapter_initalize_args = slack.mock.call_args_list[0]
    args, kwargs = slack_adapter_initalize_args
    assert slack_installation.bot_access_token in args

    post_message_args = slack.mock.call_args_list[-1]
    args, kwargs = post_message_args
    assert "does it make a sound" in kwargs["message"]
    assert "general" in kwargs["channel"]
예제 #2
0
def test_post_github_summary_task__integration(
    session, create_user, t_minus_one_day, patched_slack
):
    channel_info = Channel(name="general", id="idz", members=["user1", "user2"])
    slack = patched_slack(channel_info=channel_info)
    create_user(slack_id="user1", github_username="******")

    # Act
    fetch_github_summary_post_to_slack("general", boundary_dt=t_minus_one_day)

    # Assert
    post_message_args = slack.mock.call_args_list[-1]
    args, kwargs = post_message_args
    assert "<@user1>" in kwargs["message"]
예제 #3
0
def test_fetch_github_summary_post_to_slack_with_no_users(
    session, t_minus_one_day, patched_slack, patched_github_user_events
):
    # Arrange
    boundary_dt = t_minus_one_day
    channel_info = Channel(name="general", id="idz", members=["user1", "user2"])
    slack = patched_slack(channel_info=channel_info)
    patched_github_user_events(messages=["a", "b"])

    # Act
    fetch_github_summary_post_to_slack("general", boundary_dt=boundary_dt)

    # Assert
    post_message_args = slack.mock.call_args_list[-1]
    args, kwargs = post_message_args
    assert "does it make a sound" in kwargs["message"]
    assert "idz" in kwargs["channel_id"]
예제 #4
0
def test_fetch_github_summary_post_to_slack_with_activity(
    session, create_user, t_minus_one_day, patched_slack, patched_github_user_events
):
    # Arrange
    boundary_dt = t_minus_one_day
    create_user(slack_id="user1", github_username="******")
    create_user(slack_id="user2", github_username="******")
    channel_info = Channel(name="general", id="idz", members=["user1", "user2"])
    slack = patched_slack(channel_info=channel_info)
    patched_github_user_events(messages=["a", "b"])

    # Act
    fetch_github_summary_post_to_slack("general", boundary_dt=boundary_dt)

    # Assert
    post_message_args = slack.mock.call_args_list[-1]
    args, kwargs = post_message_args
    assert "ab" in kwargs["message"]
예제 #5
0
def test_post_github_summary_task__integration(session, factory,
                                               t_minus_one_day, patched_slack):
    channel = "general"
    github_summary_config = factory.GitHubSummaryConfiguration(channel=channel)
    slack_installation = github_summary_config.slack_installation
    factory.GitHubSummaryUser(slack_id="user1",
                              github_username="******",
                              installation=slack_installation)

    channel_info = Channel(name="general", members=["user1", "user2"])
    slack = patched_slack(channel_info=channel_info)

    # Act
    fetch_github_summary_post_to_slack(installation_id=slack_installation.id,
                                       boundary_dt=t_minus_one_day)

    # Assert
    slack_adapter_initalize_args = slack.mock.call_args_list[0]
    args, kwargs = slack_adapter_initalize_args
    assert slack_installation.bot_access_token in args

    post_message_args = slack.mock.call_args_list[-1]
    args, kwargs = post_message_args
    assert "<@user1>" in kwargs["message"]