def test_update_song(): setup_mocks() new_attr = {'title': 'new song title'} updated_song = {**mock_song, **new_attr} response = update_song({}, {}, updated_song) assert response['message'] == 'success' and response['song'][ 'title'] == 'new song title'
def test_update_composer(): setup_mocks() new_attr = {'fullName': 'Ornett Coleman'} updated_composer = {**mock_composer, **new_attr} response = update_composer({}, {}, updated_composer) assert response['message'] == 'success' and response['composer'][ 'fullName'] == 'Ornett Coleman'
def test_send_verification(): setup_mocks() client = boto3.client("sns", region_name="us-east-1") client.create_topic(Name="some-topic") resp = client.create_topic(Name="some-topic") arn = resp["TopicArn"] client.subscribe(TopicArn=arn, Protocol="sms", Endpoint=phone) resp = send_verification(None, None, phone) assert resp['status'] == 200
def test_get_me(): setup_mocks() user = { 'pk': 'user#123', 'sk': phone, } table().put_item(Item=user) auth = jwt.encode(user, os.environ['API_SECRET'], algorithm='HS256') token = auth.decode('utf8') info = MockObject info.context = MockObject info.context.headers = {"Auth": token} resp = get_me(None, info) assert resp['id'] == '123' assert resp['phone'] == phone
def test_resolve_hang(): setup_mocks() hang = resolve_hang({}, {}, "1") assert hang == mock_hang
def test_create_hang(): setup_mocks() response = create_hang({}, {}, mock_create_hang) assert response['message'] == 'success' and response['hang']['name'] == 'Crimps'
def test_resolve_hang(): setup_mocks() hangs = list(resolve_hangs({'hangs': ["1", "2"]}, {})) assert hangs == [mock_hang, another_mock_hang]
def test_resolve_composer(): setup_mocks() composer = resolve_composer({}, {}, "c1") assert composer == mock_composer
def test_create_composer(): setup_mocks() response = create_composer({}, {}, mock_create_composer) assert response['message'] == 'success' and response['composer'][ 'fullName'] == 'Duke Ellington'
def test_get_composers(): setup_mocks() composers = get_composers({}, {}, "") assert composers == [mock_composer]
def test_verify_user(): setup_mocks() table().put_item(Item=mock_verification) resp = verify_user(None, None, {'phone': phone, 'code': '123456'}) assert resp['status'] == 200 assert resp['auth'] != None
def test_resolve_song(): setup_mocks() song = resolve_song({}, {}, "1") assert song == mock_song
def test_create_song(): setup_mocks() response = create_song({}, {}, mock_create_song) assert response['message'] == 'success' and response['song'][ 'title'] == 'It don\'t mean a thing'
def test_get_songs(): setup_mocks() songs = get_songs({}, {}, "") assert songs == [mock_song, another_mock_song]
def test_resolve_song(): setup_mocks() songs = list(resolve_songs({'songs': ["1", "2"]}, {})) assert songs == [mock_song, another_mock_song]