Skip to content

Commit

Permalink
Fix bug with input response and improve test to validate it
Browse files Browse the repository at this point in the history
  • Loading branch information
hynnot committed Feb 3, 2025
1 parent d4398d9 commit d4fc376
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ async def list_measurements(
probe_asn="AS{}".format(row["probe_asn"]),
test_name=row["test_name"],
measurement_start_time=row["measurement_start_time"],
input_=row["input"],
input=row["input"],
anomaly=row["anomaly"] == "t", # TODO: This is wrong
confirmed=row["confirmed"] == "t",
failure=row["msm_failure"] == "t",
Expand Down
12 changes: 9 additions & 3 deletions ooniapi/services/oonimeasurements/tests/test_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ def test_list_measurements_with_one_value_to_filters(client, filter_param, filte
assert result[filter_param] == filter_value, result


def test_list_measurements_with_one_value_to_filters_not_in_the_result(client):
def test_list_measurements_with_one_value_to_filters_not_present_in_the_result(client):
domain = "cloudflare-dns.com"
params = {
"domain": "cloudflare-dns.com",
"domain": domain,
}

response = client.get(route, params=params)

json = response.json()
assert isinstance(json["results"], list), json
assert len(json["results"]) > 0
for result in json["results"]:
assert domain in result["input"], result


@pytest.mark.parametrize(
Expand All @@ -80,12 +83,15 @@ def test_list_measurements_with_multiple_values_to_filters(client, filter_param,


def test_list_measurements_with_multiple_values_to_filters_not_in_the_result(client):
domainCollection = "cloudflare-dns.com, adblock.doh.mullvad.net, 1.1.1.1"
params = {
"domain": "cloudflare-dns.com, adblock.doh.mullvad.net, 1.1.1.1",
"domain": domainCollection
}

response = client.get(route, params=params)

json = response.json()
assert isinstance(json["results"], list), json
assert len(json["results"]) > 0
for result in json["results"]:
assert any(domain in result["input"] for domain in domainCollection), result

0 comments on commit d4fc376

Please sign in to comment.