コード例 #1
0
def test_standup_start_invalid_channel(url, user_1, user_2, public_channel_1):
    """Testing invalid channel_ids
    """
    error = request_standup_start(url, user_2['token'], 0, 10)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_2['token'], -1, 10)
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #2
0
def test_standup_start_invalid_length(url, user_1, user_2, public_channel_1):
    """Testing invalid time length
    """
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], -10)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 0)
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #3
0
def test_standup_start_unauthorized_user(url, user_1, user_2, user_3,
                                         public_channel_1):
    """(Assumption testing) Testing when a user who is not part of the channel
       tries to start a standup
    """
    error = request_standup_start(url, user_2['token'],
                                  public_channel_1['channel_id'], 2)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_3['token'],
                                  public_channel_1['channel_id'], 2)
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #4
0
def test_standup_start_invalid_token(url, user_1, user_2, user_3, user_4,
                                     public_channel_1):
    """Testing invalid token for users
    """
    error = request_standup_start(url, user_2['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_3['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_4['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #5
0
def test_standup_send_unauthorized_user(url, user_1, user_2, user_3,
                                        public_channel_1):
    """Testing when a user who is not part of the channel tries to send a standup to
       that channel
    """
    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    information = request_standup_active(
        url, user_1['token'], public_channel_1['channel_id']).json()
    assert information['is_active']
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    error = request_standup_send(url, user_2['token'],
                                 public_channel_1['channel_id'], 'Hey')
    assert error.status_code == AccessError.code
    error = request_standup_send(url, user_3['token'],
                                 public_channel_1['channel_id'], 'Hey')
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #6
0
def test_standup_send_more_than_1000_char(url, user_1, public_channel_1):
    """Testing when the message to send via standup send is over 1000 characters
    """
    message_str_1 = ("Hello" * 250)
    message_str_2 = ("HI " * 500)
    message_str_3 = ("My name is blah" * 100)

    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    error = request_standup_send(url, user_1['token'],
                                 public_channel_1['channel_id'], message_str_1)
    assert error.status_code == InputError.code
    error = request_standup_send(url, user_1['token'],
                                 public_channel_1['channel_id'], message_str_2)
    assert error.status_code == InputError.code
    error = request_standup_send(url, user_1['token'],
                                 public_channel_1['channel_id'], message_str_3)
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #7
0
def test_standup_active_not_active(url, user_1, user_2, user_3,
                                   public_channel_1):
    """Testing when standup is not active
    """
    assert request_channel_invite(url, user_1['token'],
                                  public_channel_1['channel_id'],
                                  user_2['u_id']).json() == {}
    assert request_channel_invite(url, user_2['token'],
                                  public_channel_1['channel_id'],
                                  user_3['u_id']).json() == {}

    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)
    time.sleep(4)

    information = request_standup_active(
        url, user_1['token'], public_channel_1['channel_id']).json()
    assert not information['is_active']
    assert information['time_finish'] == None

    information = request_standup_active(
        url, user_2['token'], public_channel_1['channel_id']).json()
    assert not information['is_active']
    assert information['time_finish'] == None

    information = request_standup_active(
        url, user_3['token'], public_channel_1['channel_id']).json()
    assert not information['is_active']
    assert information['time_finish'] == None
    requests.delete(f'{url}/clear')
コード例 #8
0
def test_standup_send_working_example(url, user_1, user_2, user_3,
                                      public_channel_1):
    """Testing when standup send is working, via message collation
    """
    assert request_channel_invite(url, user_1['token'],
                                  public_channel_1['channel_id'],
                                  user_2['u_id']).json() == {}
    assert request_channel_invite(url, user_2['token'],
                                  public_channel_1['channel_id'],
                                  user_3['u_id']).json() == {}

    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    on_list = False
    user_one_handle = request_user_details(
        url, user_1['token'], user_1['u_id']).json()['user']['handle_str']
    assert request_standup_send(url, user_1['token'],
                                public_channel_1['channel_id'],
                                'Pizza!').json() == {}
    message_data = request_channel_messages(url, user_1['token'],
                                            public_channel_1['channel_id'],
                                            0).json()
    for messages in message_data['messages']:
        if messages['message'] == f'{user_one_handle}: Pizza!':
            on_list = True
    assert not on_list

    assert request_standup_send(url, user_2['token'],
                                public_channel_1['channel_id'],
                                'Water!').json() == {}
    assert request_standup_send(url, user_3['token'],
                                public_channel_1['channel_id'],
                                'Melon!').json() == {}
    time.sleep(4)

    on_list = False
    user_two_handle = request_user_details(
        url, user_2['token'], user_2['u_id']).json()['user']['handle_str']
    user_three_handle = request_user_details(
        url, user_3['token'], user_3['u_id']).json()['user']['handle_str']
    message_data = request_channel_messages(url, user_1['token'],
                                            public_channel_1['channel_id'],
                                            0).json()
    for messages in message_data['messages']:
        if messages[
                'message'] == f'{user_one_handle}: Pizza!\n{user_two_handle}: Water!\n{user_three_handle}: Melon!':
            on_list = True
    assert on_list
    requests.delete(f'{url}/clear')
コード例 #9
0
def test_standup_start_already_started(url, user_1, public_channel_1):
    """Testing when a standup is already running in channel 
    """
    standup_duration = 120
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 5)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 50)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 120)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 240)
    assert error.status_code == InputError.code
    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 360)
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #10
0
def test_standup_start_expired_token(url, user_1, user_2, user_3, user_4,
                                     public_channel_1):
    """Testing expired token for users which have logged out
    """
    log_out = requests.post(f'{url}/auth/logout',
                            json={
                                'token': user_1['token']
                            }).json()
    assert log_out['is_success']
    log_out = requests.post(f'{url}/auth/logout',
                            json={
                                'token': user_2['token']
                            }).json()
    assert log_out['is_success']
    log_out = requests.post(f'{url}/auth/logout',
                            json={
                                'token': user_3['token']
                            }).json()
    assert log_out['is_success']
    log_out = requests.post(f'{url}/auth/logout',
                            json={
                                'token': user_4['token']
                            }).json()
    assert log_out['is_success']

    error = request_standup_start(url, user_1['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_2['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_3['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    error = request_standup_start(url, user_4['token'],
                                  public_channel_1['channel_id'], 10)
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #11
0
def test_standup_send_empty_string(url, user_1, public_channel_1):
    """Testing when the message to send via standup send is empty string
    """
    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration - STANDUP_DELAY) <= information['time_finish'] and\
    information['time_finish'] <= (curr_time + standup_duration + STANDUP_DELAY)

    error = request_standup_send(url, user_1['token'],
                                 public_channel_1['channel_id'], '')
    assert error.status_code == InputError.code
    error = request_standup_send(url, user_1['token'],
                                 public_channel_1['channel_id'], "")
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #12
0
def test_standup_start_working_example(url, user_1, user_2, user_3,
                                       public_channel_1):
    """Testing when standup is working, via message collation
    """
    assert request_channel_invite(url, user_1['token'],
                                  public_channel_1['channel_id'],
                                  user_2['u_id']).json() == {}
    assert request_channel_invite(url, user_2['token'],
                                  public_channel_1['channel_id'],
                                  user_3['u_id']).json() == {}

    standup_duration = 2
    curr_time = int(datetime.now(tz=timezone.utc).timestamp())
    information = request_standup_start(url, user_1['token'],
                                        public_channel_1['channel_id'],
                                        standup_duration).json()
    assert (curr_time + standup_duration -
            STANDUP_DELAY) <= information['time_finish']
    assert information['time_finish'] <= (curr_time + standup_duration +
                                          STANDUP_DELAY)

    payload = request_standup_active(url, user_1['token'],
                                     public_channel_1['channel_id']).json()
    assert payload['is_active'] == True

    on_list = False
    user_one_handle = request_user_details(
        url, user_1['token'], user_1['u_id']).json()['user']['handle_str']
    assert request_standup_send(url, user_1['token'],
                                public_channel_1['channel_id'],
                                'Hey guys!').json() == {}
    message_data = request_channel_messages(url, user_1['token'],
                                            public_channel_1['channel_id'],
                                            0).json()
    for messages in message_data['messages']:
        if messages['message'] == f'{user_one_handle}: Hey guys!':
            on_list = True
    assert not on_list

    on_list = False
    user_two_handle = request_user_details(
        url, user_2['token'], user_2['u_id']).json()['user']['handle_str']
    assert request_standup_send(url, user_2['token'],
                                public_channel_1['channel_id'],
                                'Its working!').json() == {}
    message_data = request_channel_messages(url, user_1['token'],
                                            public_channel_1['channel_id'],
                                            0).json()
    for messages in message_data['messages']:
        if messages[
                'message'] == f'{user_one_handle}: Hey guys!\n{user_two_handle}: Its working!':
            on_list = True
    assert not on_list

    assert request_standup_send(url, user_3['token'],
                                public_channel_1['channel_id'],
                                'Wohoo!').json() == {}
    payload = request_standup_active(url, user_1['token'],
                                     public_channel_1['channel_id']).json()
    assert payload['is_active'] == True

    time.sleep(4)
    payload = request_standup_active(url, user_1['token'],
                                     public_channel_1['channel_id']).json()
    assert payload['is_active'] == False

    on_list = False
    user_three_handle = request_user_details(
        url, user_3['token'], user_3['u_id']).json()['user']['handle_str']
    message_data = request_channel_messages(url, user_1['token'],
                                            public_channel_1['channel_id'],
                                            0).json()
    for messages in message_data['messages']:
        if messages[
                'message'] == f'{user_one_handle}: Hey guys!\n{user_two_handle}: Its working!\n{user_three_handle}: Wohoo!':
            on_list = True
    assert on_list
    requests.delete(f'{url}/clear')