Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / tools / tryselect / test / test_chooser.py
blob3d60a0f8d4490c28f7e93ebdc9b27577380d044f
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import multiprocessing
7 import mozunit
8 import pytest
9 from tryselect.selectors.chooser.app import create_application
11 TASKS = [
13 "kind": "build",
14 "label": "build-windows",
15 "attributes": {
16 "build_platform": "windows",
20 "kind": "test",
21 "label": "test-windows-mochitest-e10s",
22 "attributes": {
23 "unittest_suite": "mochitest-browser-chrome",
24 "mochitest_try_name": "mochitest-browser-chrome",
30 @pytest.fixture
31 def queue():
32 return multiprocessing.Queue()
35 @pytest.fixture
36 def app(tg, queue):
37 app = create_application(tg, queue)
38 app.config["TESTING"] = True
40 ctx = app.app_context()
41 ctx.push()
42 yield app
43 ctx.pop()
46 def test_try_chooser(app, queue: multiprocessing.Queue):
47 client = app.test_client()
49 response = client.get("/")
50 assert response.status_code == 200
52 expected_output = [
53 b"""<title>Try Chooser Enhanced</title>""",
54 b"""<input class="filter" type="checkbox" id=windows name="build" value='{"build_platform": ["windows"]}' onchange="console.log('checkbox onchange triggered');apply();">""", # noqa
55 b"""<input class="filter" type="checkbox" id=mochitest-browser-chrome name="test" value='{"unittest_suite": ["mochitest-browser-chrome"]}' onchange="console.log('checkbox onchange triggered');apply();">""", # noqa
58 for expected in expected_output:
59 assert expected in response.data
61 response = client.post("/", data={"action": "Cancel"})
62 assert response.status_code == 200
63 assert b"You may now close this page" in response.data
64 assert queue.get() == []
66 response = client.post("/", data={"action": "Push", "selected-tasks": ""})
67 assert response.status_code == 200
68 assert b"You may now close this page" in response.data
69 assert queue.get() == []
71 response = client.post(
72 "/",
73 data={
74 "action": "Push",
75 "selected-tasks": "build-windows\ntest-windows-mochitest-e10s",
78 assert response.status_code == 200
79 assert b"You may now close this page" in response.data
80 assert set(queue.get()) == set(["build-windows", "test-windows-mochitest-e10s"])
83 if __name__ == "__main__":
84 mozunit.main()