-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): prepare for WebConnectivity A/B testing #792
base: master
Are you sure you want to change the base?
Conversation
print("running", tc["name"]) | ||
j = tc["inputs"] | ||
c = client.post("/api/v1/check-in", json=j).json | ||
assert c.get("conf", {}).get("features", {}).get("webconnectivity_0.5", False) == tc["expect"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests inside this file are disabled, so we don't run the new test above by default. I managed to run tests locally but I then realized some of them are failing as detailed below:
________________________________ test_check_in _________________________________
client = <FlaskClient <Flask 'ooniapi.app'>>, mocks = None
def test_check_in(client, mocks):
j = dict(
probe_cc="US",
probe_asn="AS1234",
on_wifi=True,
charging=False,
)
c = postj(client, "/api/v1/check-in", **j)
assert c["v"] == 1
assert c["utc_time"].startswith("20")
assert c["utc_time"].endswith("Z")
assert "T" in c["utc_time"]
assert len(c["utc_time"]) == 20
urls = c["tests"]["web_connectivity"]["urls"]
> assert len(urls) == 20, urls
E AssertionError: [{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code':...XX', 'url': 'https://twitter.com/'}, {'category_code': 'CULTR', 'country_code': 'XX', 'url': 'https://www.ushmm.org/'}]
E assert 5 == 20
E + where 5 = len([{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code':...XX', 'url': 'https://twitter.com/'}, {'category_code': 'CULTR', 'country_code': 'XX', 'url': 'https://www.ushmm.org/'}])
tests/integ/test_probe_services_nodb.py:143: AssertionError
[...]
_______________________ test_check_in_url_category_news ________________________
client = <FlaskClient <Flask 'ooniapi.app'>>, mocks = None
def test_check_in_url_category_news(client, mocks):
j = dict(
on_wifi=True,
charging=True,
web_connectivity=dict(category_codes=["NEWS"]),
)
c = postj(client, "/api/v1/check-in", **j)
assert c["v"] == 1
urls = c["tests"]["web_connectivity"]["urls"]
> assert len(urls) == 100, urls
E AssertionError: [{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code': 'XX', 'url': 'https://ncac.org/'}]
E assert 2 == 100
E + where 2 = len([{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code': 'XX', 'url': 'https://ncac.org/'}])
tests/integ/test_probe_services_nodb.py:164: AssertionError
[...]
_______________________ test_check_in_url_category_multi _______________________
client = <FlaskClient <Flask 'ooniapi.app'>>, mocks = None
def test_check_in_url_category_multi(client, mocks):
j = dict(
probe_cc="IT",
on_wifi=True,
charging=True,
web_connectivity=dict(category_codes=["NEWS", "MILX", "FILE"]),
)
c = postj(client, "/api/v1/check-in", **j)
assert c["v"] == 1
urls = c["tests"]["web_connectivity"]["urls"]
> assert len(urls) == 100, urls
E AssertionError: [{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code': 'XX', 'url': 'https://ncac.org/'}]
E assert 2 == 100
E + where 2 = len([{'category_code': 'NEWS', 'country_code': 'XX', 'url': 'http://ncac.org/'}, {'category_code': 'NEWS', 'country_code': 'XX', 'url': 'https://ncac.org/'}])
tests/integ/test_probe_services_nodb.py:185: AssertionError
[...]
_______________ test_check_in_url_prioritization_category_codes ________________
client = <FlaskClient <Flask 'ooniapi.app'>>, mocks = None
def test_check_in_url_prioritization_category_codes(client, mocks):
c = getjson(
client,
"/api/v1/test-list/urls?category_codes=NEWS,HUMR&country_code=US&limit=100",
)
assert "metadata" in c
> assert c["metadata"] == {
"count": 100,
"current_page": -1,
"limit": -1,
"next_url": "",
"pages": 1,
}
E AssertionError: assert {'count': 2, ...url': '', ...} == {'count': 100...url': '', ...}
E Omitting 4 identical items, use -vv to show
E Differing items:
E {'count': 2} != {'count': 100}
E Use -v to get the full diff
tests/integ/test_probe_services_nodb.py:222: AssertionError
============== 4 failed, 16 passed, 3 skipped, 1 warning in 4.91s ==============
I will see if I can obviously fix them and then re-enabled them. It seems a bit of a bummer to not run tests we have written.
See ooni/probe#2555