def test_helper_get_users_in_channel_returns_users(): # Given channel_id = "foo" channel_ids = [channel_id] channel_names = ["foo"] expected_user_ids = ["1", "2", "3"] expected_user_names = [ "a", "b", "c" ] # needed for mock class even though unused by this test mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_public_channels=channel_ids, injectable_channel_names=channel_names, injectable_user_ids=expected_user_ids, injectable_user_names=expected_user_names, ) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_user_names = sut.helper_get_users_in_channel(channel_names[0]) # Then assert expected_user_names == actual_user_names
def test_helper_get_user_ids_returns_empty_list_when_found_zero_user_ids(): # Given expected_user_ids = [] mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_user_ids=expected_user_ids) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_user_ids = sut.helper_get_user_ids() # Then assert expected_user_ids == actual_user_ids
def test_helper_get_private_channel_ids_returns_private_channel_ids(): # Given expected_private_channel_ids = ["1", "2", "3"] mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_private_channels=expected_private_channel_ids) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_private_channel_ids = sut.helper_get_private_channel_ids() # Then assert expected_private_channel_ids == actual_private_channel_ids
def test_helper_get_user_names_returns_empty_list_when_found_zero_user_names(): # Given user_ids = ["1", "2", "3"] # needed for mock class even though unused by this test expected_user_names = [] mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_user_ids=user_ids, injectable_user_names=expected_user_names) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_user_names = sut.helper_get_user_names() # Then assert expected_user_names == actual_user_names
def test_helper_user_id_to_user_name_returns_user_name_when_found(): # Given expected_user_names = ["foo"] expected_user_ids = ["bar"] mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_user_ids=expected_user_ids, injectable_user_names=expected_user_names) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_user_name = sut.helper_user_id_to_user_name(expected_user_ids[0]) # Then assert expected_user_names[0] is actual_user_name
def test_helper_get_public_channel_ids_returns_empty_list_when_found_zero_public_channel_ids( ): # Given expected_public_channel_ids = [] user_names = ["a", "b", "c"] # needed for mock class even though unused by this test mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_public_channels=expected_public_channel_ids, injectable_user_names=user_names) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_public_channel_ids = sut.helper_get_public_channel_ids() # Then assert expected_public_channel_ids == actual_public_channel_ids
def test_start_errors_out_if_slackclient_rtm_has_invalid_ok(): # Given sut = SimpleSlackBot("mock slack bot token") sut.connect = mock_connect mock_python_slackclient = tests.common.mocks.MockPythonSlackclient(False) sut._python_slackclient = mock_python_slackclient mock_listen = MockListen() sut.listen = mock_listen.mock_listen # When sut.start() # Then assert mock_listen.was_mock_listen_called is False
def test_helper_user_id_to_user_name_returns_none_when_nothing_is_found(): # Given expected_user_names = [] expected_user_ids = [] mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_user_ids=expected_user_ids, injectable_user_names=expected_user_names) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_user_name = sut.helper_user_id_to_user_name(expected_user_ids) # Then assert None is actual_user_name
def test_helper_channel_id_to_channel_name_returns_none_when_nothing_is_found( ): # Given expected_channel_names = [] expected_channel_ids = [] user_names = [] # needed for mock class even though unused by this test mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_public_channels=expected_channel_ids, injectable_channel_names=expected_channel_names, injectable_user_names=user_names, ) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_channel_id = sut.helper_channel_id_to_channel_name( expected_channel_ids) # Then assert None is actual_channel_id
def test_helper_channel_name_to_channel_id_returns_channel_name_when_found(): # Given expected_channel_ids = ["foo"] expected_channel_names = ["bar"] user_names = ["baz" ] # needed for mock class even though unused by this test mock_python_slackclient = tests.common.mocks.MockPythonSlackclient( injectable_public_channels=expected_channel_ids, injectable_channel_names=expected_channel_names, injectable_user_names=user_names, ) sut = SimpleSlackBot() sut._python_slackclient = mock_python_slackclient # When actual_channel_id = sut.helper_channel_name_to_channel_id( expected_channel_names[0]) # Then assert expected_channel_ids[0] is actual_channel_id