feat(api): prepare for WebConnectivity A/B testing#792
Open
bassosimone wants to merge 3 commits intomasterfrom
Open
feat(api): prepare for WebConnectivity A/B testing#792bassosimone wants to merge 3 commits intomasterfrom
bassosimone wants to merge 3 commits intomasterfrom
Conversation
bassosimone
commented
Feb 20, 2024
| 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"] |
Contributor
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See ooni/probe#2555