Esempio n. 1
0
def test_get_participant_none():
    participant1 = retro.create_mock_participant(token='junk')
    participant2 = retro.create_mock_participant(token='whatever')
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    found_participant = token.get_participant('something_not_above', a_retro)

    assert found_participant is None
Esempio n. 2
0
def test_token_is_valid_false():
    participant1 = retro.create_mock_participant(token='junk')
    participant2 = retro.create_mock_participant(token='whatever')
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    result = token.token_is_valid('something_not_above', a_retro)

    assert result is False
Esempio n. 3
0
def test_get_participant_found():
    test_token = 'asdf-jkl'
    participant1 = retro.create_mock_participant(token='junk')
    participant2 = retro.create_mock_participant(token=test_token)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    found_participant = token.get_participant(test_token, a_retro)

    assert found_participant is participant2
Esempio n. 4
0
def test__find_participant_none():
    participant1 = retro.create_mock_participant(name='lame_name')
    participant2 = retro.create_mock_participant(name='whatever_name')
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    found_participant = token._find_participant(
        lambda participant: participant.name == 'something_not_above', a_retro)

    assert found_participant is None
Esempio n. 5
0
def test_token_is_admin_false():
    test_token = 'asdf-jkl'
    participant1 = retro.create_mock_participant(token='junk', admin=False)
    participant2 = retro.create_mock_participant(token=test_token, admin=False)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    result = token.token_is_admin(test_token, a_retro)

    assert result is False
Esempio n. 6
0
def test_token_is_valid_true():
    test_token = 'asdf-jkl'
    participant1 = retro.create_mock_participant(token='junk')
    participant2 = retro.create_mock_participant(token=test_token)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    result = token.token_is_valid(test_token, a_retro)

    assert result is True
Esempio n. 7
0
def test__find_participant_found():
    test_name = 'DogCow'
    participant1 = retro.create_mock_participant(name='lame_name')
    participant2 = retro.create_mock_participant(name=test_name)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    found_participant = token._find_participant(
        lambda participant: participant.name == test_name, a_retro)

    assert found_participant is participant2
Esempio n. 8
0
def test__reset_ready_statuses():
    participant1 = retro.create_mock_participant(ready=True)
    participant2 = retro.create_mock_participant(ready=False)
    participant3 = retro.create_mock_participant(ready=True)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2, participant3])

    Service._reset_ready_statuses(a_retro)

    for participant in a_retro.participants:
        assert participant.ready is False
Esempio n. 9
0
def test__send_retro_update(mock_os_module, mock_boto3_module):
    mock_retro = retro.create_mock_retro(participants=[
        retro.create_mock_participant(
            token='f1fa1211-2203-44b6-8d85-db4ef317dff1:connectionId1'),
        retro.create_mock_participant(
            token='f1fa1211-2203-44b6-8d85-db4ef317dff2')
    ])
    mock_client = MagicMock()
    mock_os_module.environ = {'WEBSOCKET_ENDPOINT': 'moof'}
    mock_boto3_module.Session().client.return_value = mock_client

    Service._send_retro_update(mock_retro)

    mock_client.post_to_connection.assert_called_once()
Esempio n. 10
0
def test_mark_user_as_ready(mock_send_retro_update):
    user_token = 'asdf-jkl'
    is_ready = True
    participants = [
        retro.create_mock_participant('DogCow', 'moof-token', ready=False),
        retro.create_mock_participant('halprin', user_token, ready=False)
    ]
    a_retro = retro.create_mock_retro(participants=participants)

    Service.mark_user_as_ready(user_token, is_ready, a_retro)

    assert participants[0].ready is False
    assert participants[1].ready is is_ready
    a_retro.save.assert_called_with()
    mock_send_retro_update.assert_called_once()
Esempio n. 11
0
    def test_post_create_new_retro(self, mock_service_validation,
                                   mock_service_view, mock_token):
        request_body = {'retroName': 'Sprint 26', 'adminName': 'halprin'}
        a_request = request.create_mock_request(request_body)
        new_retro_id = 'awesome_retro_id'
        new_admin_id = 'sweet_user_id'
        mock_new_retro = retro.create_mock_retro(
            id=new_retro_id,
            name=request_body['retroName'],
            participants=[
                retro.create_mock_participant(token=new_admin_id,
                                              name=request_body['adminName'],
                                              admin=True)
            ])
        mock_service_view.create_retro.return_value = mock_new_retro

        object_under_test = RetroView()
        response = object_under_test.post(a_request)

        assert response.status_code == 201
        assert response.headers[
            validators.content_type] == content_type_application_json
        assert json.loads(response.body) == {
            'retroId': new_retro_id,
            'token': new_admin_id
        }
Esempio n. 12
0
def test__construct_yourself_info():
    test_token = 'asdf-jkl'
    test_name = 'Johny'
    test_ready = True
    test_admin = True
    participant1 = retro.create_mock_participant(token='junk')
    participant2 = retro.create_mock_participant(name=test_name,
                                                 token=test_token,
                                                 ready=test_ready,
                                                 admin=test_admin)
    a_retro = retro.create_mock_retro(
        participants=[participant1, participant2])

    yourself = Service._construct_yourself_info(a_retro, test_token)

    assert yourself['name'] == test_name
    assert yourself['ready'] == test_ready
    assert yourself['admin'] == test_admin
Esempio n. 13
0
def test__sanitize_participant_list_when_admin():
    your_token = 'a-token'
    your_participant = retro.create_mock_participant('your_name',
                                                     token=your_token,
                                                     ready=False,
                                                     admin=True)
    another_participant = retro.create_mock_participant('another_name',
                                                        token='another-token',
                                                        ready=True,
                                                        admin=False)
    a_retro = retro.create_mock_retro(
        current_step=RetroStep.ADDING_ISSUES,
        participants=[your_participant, another_participant])

    sanitized_participants = Service._sanitize_participant_list(
        a_retro, your_token)

    assert len(sanitized_participants) == 2
    assert sanitized_participants[0]['name'] == your_participant.name
    assert sanitized_participants[0]['ready'] == your_participant.ready
    assert sanitized_participants[1]['name'] == another_participant.name
    assert sanitized_participants[1]['ready'] == another_participant.ready
Esempio n. 14
0
def test_sanitize_retro_for_user_and_step():
    size = 4
    mock_user_token = 'user-token'
    mock_id = 'crazy_id'
    mock_name = 'Moof!'

    groups = [retro.create_mock_group(id='id'+str(index))for index in range(size)]

    mock_retro = retro.create_mock_retroV2(id=mock_id, name=mock_name, groups=groups,
                                           issues=[retro.create_mock_issueV2()],
                                           participants=[retro.create_mock_participant(token=mock_user_token)])

    sanitized_retro = ServiceV2.sanitize_retro_for_user_and_step(mock_retro, mock_user_token)

    assert mock_id == sanitized_retro['id']
    assert mock_name == sanitized_retro['name']
    assert len(mock_retro.participants) == len(sanitized_retro['participants'])
    assert len(mock_retro.issues) == len(sanitized_retro['issues'])
    assert size == len(sanitized_retro['groups'])
    assert 'yourself' in sanitized_retro
Esempio n. 15
0
def test_sanitize_retro_for_user_and_step():
    id = 'asdf-jkl'
    name = 'Sprint 28'
    current_step = RetroStep.ADDING_ISSUES.value
    user_token = 'whatever'
    participant = retro.create_mock_participant(token=user_token)
    a_retro = retro.create_mock_retro(id,
                                      name,
                                      current_step,
                                      participants=[participant])

    sanitized_retro = Service.sanitize_retro_for_user_and_step(
        a_retro, user_token)

    assert sanitized_retro['id'] == id
    assert sanitized_retro['name'] == name
    assert sanitized_retro['currentStep'] == current_step
    assert sanitized_retro['participants'] is not None
    assert sanitized_retro['issues'] is not None
    assert sanitized_retro['yourself'] is not None