def test_query_hypothesis_with_real_url(query): print("running test_query_hyphotesis_for_query_api()") try: response = query_api(query) if len(response) > 0: assert response == 'http://api.skywatch.co/?types=star&vmag=gt0' else: assert response == "" except Exception as e: reject()
def search_string(): """ Get string search :return: code 200 and json if ok, 400 if malformed string """ src_str = request.form['search'] is_valid_str = validate_string(src_str) if is_valid_str: my_url = query_api(src_str) is_valid_url = is_url_valid(my_url) if my_url != "" and is_valid_url: return jsonify({"url": my_url}) else: return make_response( jsonify({"Error": "search url is not valid!"}), 400) return make_response(jsonify({"Error": "search string is not valid!"}), 400)
def test_query_hypothesis_with_empty(query): print("running test_query_hyphotesis_for_query_api()") try: assert query_api(query) == "" except Exception as e: reject()
def test_url_valid(self): url_ok = 'http://api.skywatch.co/?types=star+galaxy+interstellar_matter' url_from_query = query_api("stars, galaxies and interstellar matter") assert url_from_query == url_ok assert is_url_valid(url_from_query) assert is_url_valid(url_ok)
def test_mult_physical_with_mult_criteria(self): assert query_api("stars, galaxies with mes = jpl+flux_v, redshift <= 0.01 and plx >= 2") == \ 'http://api.skywatch.co/?types=star+galaxy&mes=jpl+flux_v&redshift=lte0.01&plx=gte2'
def test_physical_criteria_unordered(self): assert query_api("stars, redshift > 0.001, galaxies") == \ 'http://api.skywatch.co/?types=star+galaxy&redshift=gt0.001'
def test_only_criteria(self): assert query_api("redshift > 0.001, plx < 1 and mes = jpl+flux_v") == \ 'http://api.skywatch.co/?redshift=gt0.001&plx=lt1&mes=jpl+flux_v'
def test_physical_with_multiple_criteria(self): assert query_api("galaxies with redshift > 0.001, plx < 1 and mes = jpl+flux_v") == \ 'http://api.skywatch.co/?types=galaxy&redshift=gt0.001&plx=lt1&mes=jpl+flux_v'
def test_only_physical(self): assert query_api( "stars, galaxies and interstellar matter") == \ 'http://api.skywatch.co/?types=star+galaxy+interstellar_matter'
def test_physical_with_criteria(self): assert query_api("stars with vmag > 0") == \ 'http://api.skywatch.co/?types=star&vmag=gt0'