Ejemplo n.º 1
0
def test_handle_with_fine_text_returns_valid_response(event):
    body_text = '@{} $50 for reason'.format(const.USERNAME_FINED)
    event['body'] = utils.set_body_text(event['body'], body_text)
    event = utils.update_signature(event)
    dynamo.create_fine_table()
    result = fine.handle(event, {})
    assert result['body'] == json.dumps(response.create_fine_response(const.USERNAME_FINED))
Ejemplo n.º 2
0
def test_handle_with_view_submission_deletes_fine(requests_mock, event_vs):
    requests_mock.post(interaction.OPEN_VIEW_POST_URL)
    dynamo.create_fine_table()
    dynamo.add_fine(const.TEAM_ID, const.CHANNEL_ID, const.USERNAME,
                    'fine_text', const.FINE_ID)

    interaction.handle(event_vs, {})
    fines = dynamo.get_fines(const.TEAM_ID, const.CHANNEL_ID)

    assert requests_mock.call_count == 0
    assert fines == []
Ejemplo n.º 3
0
def test_handle_with_fine_text_returns_valid_response(event):
    text = '@fake_user_2 $50 for reason'
    event['body'] = utils.set_body_text(event['body'], '')
    event = utils.update_signature(event)

    dynamo.create_fine_table()
    dynamo.add_fine(const.TEAM_ID, const.CHANNEL_ID, const.USERNAME, text, const.FINE_ID)
    result = fines.handle(event, {})

    expected_fine = [{'finedBy': const.USERNAME, 'text': text, 'id': const.FINE_ID}]
    assert result['body'] == json.dumps(response.create_fines_response(expected_fine))
    
Ejemplo n.º 4
0
def test_handle_with_fine_text_saves_dynamo_item(event):
    text = '@fake_user_2 $50 for reason'
    event['body'] = utils.set_body_text(event['body'], text)
    event = utils.update_signature(event)

    dynamo.create_fine_table()
    fine.handle(event, {})
    fine_item = dynamo.get_fines(const.TEAM_ID, const.CHANNEL_ID)[0]
    
    assert fine_item['finedBy'] == const.USERNAME
    assert fine_item['text'] == text
    assert fine_item['id'] is not None
    
Ejemplo n.º 5
0
def test_handle_with_no_fines_returns_no_fines_response(event):
    event = utils.update_signature(event)
    dynamo.create_fine_table()
    result = fines.handle(event, {})
    assert result['body'] == json.dumps(response.create_no_fines_response())