コード例 #1
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')
コード例 #2
0
def test_standup_active_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 see if a standup is active in 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_active(url, user_2['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_3['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #3
0
def test_standup_active_invalid_channel(url, user_1, public_channel_1):
    """Testing invalid channel_ids
    """
    error = request_standup_active(url, user_1['token'],
                                   public_channel_1['channel_id'] + 1)
    assert error.status_code == InputError.code
    error = request_standup_active(url, user_1['token'],
                                   public_channel_1['channel_id'] - 1)
    assert error.status_code == InputError.code
    requests.delete(f'{url}/clear')
コード例 #4
0
def test_standup_active_invalid_token(url, user_1, user_2, public_channel_1):
    """Testing invalid token for users
    """
    error = request_standup_active(url, user_2['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_2['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_2['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #5
0
def test_standup_active_expired_token(url, user_1, user_2, user_3, user_4,
                                      public_channel_1):
    """Testing invalid 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_active(url, user_1['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_2['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_3['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    error = request_standup_active(url, user_4['token'],
                                   public_channel_1['channel_id'])
    assert error.status_code == AccessError.code
    requests.delete(f'{url}/clear')
コード例 #6
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')