Beispiel #1
0
def api_get_movies_by_country():
    try:
        countries = request.args.getlist('countries')
        results = get_movies_by_country(countries)
        response_object = {"titles": results}
        return jsonify(response_object), 200
    except Exception as e:
        response_object = {"error": str(e)}
        return jsonify(response_object), 400
def test_basic_country_search_shape_db(client):
    countries = ["Russia", "Japan"]
    result = get_movies_by_country(countries)
    assert len(result) == 1237
    # we should only be returning the _id and title fields
    encountered_keys = {}
    for movie in result:
        for k in movie:
            encountered_keys[k] = encountered_keys.get(k, 0) + 1

    assert len(list(encountered_keys.keys())) == 2
    assert encountered_keys["_id"] == 1237
    assert encountered_keys["title"] == 1237
Beispiel #3
0
def test_basic_country_search_shape_db(client):
    countries = ['Russia', 'Japan']
    result = get_movies_by_country(countries)
    assert len(result) == 2420
    # we should only be returning the _id and title fields
    encountered_keys = {}
    for movie in result:
        for k in movie:
            encountered_keys[k] = encountered_keys.get(k, 0) + 1

    assert len(list(encountered_keys.keys())) == 2
    assert encountered_keys['_id'] == 2420
    assert encountered_keys['title'] == 2420
def test_basic_country_search_db(client):
    countries = ["Kosovo"]
    result = get_movies_by_country(countries)
    assert len(result) == 2
Beispiel #5
0
def test_basic_country_search_db(client):
    countries = ['Kosovo']
    result = get_movies_by_country(countries)
    print("Result:", result)
    print("LenResult:", len(result))
    assert len(result) == 2