コード例 #1
0
def test_user_selects_multiple_preferences_returns_successful_response():
    lat = '39.7392358'
    long = '-104.990251'
    cuisine = 'indian'
    price = '2'
    url = '/api/v1/recommendations?latitude={}&longitude={}&categories={}&price={}'.format(
        lat, long, cuisine, price)

    client = app.test_client()
    response = client.get(url)

    assert response.status_code == 200

    response_body = response.json
    price = len(response_body['data']['attributes']['price'])

    assert price <= 2
    assert 'id' in response_body['data']
    assert 'cuisine' in response_body['data']['attributes']
    assert 'name' in response_body['data']['attributes']
    assert 'location' in response_body['data']['attributes']
    assert 'phone' in response_body['data']['attributes']
    assert 'display_phone' in response_body['data']['attributes']
    assert 'rating' in response_body['data']['attributes']
    assert 'price' in response_body['data']['attributes']
    assert 'website' in response_body['data']['attributes']
    assert response_body['data']['attributes']['is_closed'] == False
コード例 #2
0
def test_user_selects_price_preference_1_returns_successful_response():
    lat = '39.7392358'
    long = '-104.990251'
    price = '1'

    url = '/api/v1/recommendations?latitude={}&longitude={}&price={}'.format(
        lat, long, price)
    client = app.test_client()
    response = client.get(url)
    assert response.status_code == 200

    response_body = response.json
    price = len(response_body['data']['attributes']['price'])
    assert 'price' in response_body['data']['attributes']
    assert price == 1
    assert response_body['data']['attributes']['is_closed'] == False
コード例 #3
0
def test_user_enters_state_and_gets_successful_response():
    address = 'Colorado'
    url = '/api/v1/recommendations?address={}'.format(address)
    client = app.test_client()
    response = client.get(url)
    assert response.status_code == 200
    response_body = response.json
    assert 'id' in response_body['data']
    assert 'cuisine' in response_body['data']['attributes']
    assert 'name' in response_body['data']['attributes']
    assert 'location' in response_body['data']['attributes']
    assert 'phone' in response_body['data']['attributes']
    assert 'display_phone' in response_body['data']['attributes']
    assert 'rating' in response_body['data']['attributes']
    assert 'price' in response_body['data']['attributes']
    assert 'website' in response_body['data']['attributes']
    assert response_body['data']['attributes']['is_closed'] == False
コード例 #4
0
def test_user_selects_random_restaurant_option_returns_successful_response():
    lat = '39.7392358'
    long = '-104.990251'
    url = '/api/v1/random?latitude={}&longitude={}'.format(lat, long)

    client = app.test_client()
    response = client.get(url)

    assert response.status_code == 200

    response_body = response.json

    assert 'id' in response_body['data']
    assert 'cuisine' in response_body['data']['attributes']
    assert 'name' in response_body['data']['attributes']
    assert 'location' in response_body['data']['attributes']
    assert 'phone' in response_body['data']['attributes']
    assert 'display_phone' in response_body['data']['attributes']
    assert 'rating' in response_body['data']['attributes']
    assert 'price' in response_body['data']['attributes']
    assert 'photos' in response_body['data']['attributes']
コード例 #5
0
def test_homepage_returns_successful_response():
    url = '/'
    client = app.test_client()
    response = client.get(url)
    assert response.status_code == 200
コード例 #6
0
def test_homepage_returns_documentation_info():
    url = '/'
    client = app.test_client()
    response = client.get(url)
    text = response.data.decode('utf8')
    assert text == '<h1>Welcome to the Hangry AteBall API!</h1>\n<p>You can find the API documentation at\n    <a href="https://hangry-ateball-api.herokuapp.com/api/docs">https://hangry-ateball-api.herokuapp.com/api/docs</a>.\n</p>'