Mercurial > libervia-backend
comparison tests/e2e/libervia/conftest.py @ 3438:84fb41b515a1
tests (e2e/libervia/conftest): new `log_in_account1_s2` fixture
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 04 Dec 2020 12:36:06 +0100 |
parents | d4558f3cbf13 |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3437:42d6d00e4e8a | 3438:84fb41b515a1 |
---|---|
29 LIBERVIA_HOST = "libervia.test" | 29 LIBERVIA_HOST = "libervia.test" |
30 LIBERVIA_PORT_HTTPS = 8443 | 30 LIBERVIA_PORT_HTTPS = 8443 |
31 BASE_URL = f"https://{LIBERVIA_HOST}:{LIBERVIA_PORT_HTTPS}" | 31 BASE_URL = f"https://{LIBERVIA_HOST}:{LIBERVIA_PORT_HTTPS}" |
32 SIZE_DESKTOP = (1024, 728) | 32 SIZE_DESKTOP = (1024, 728) |
33 SIZE_MOBILE = (380, 640) | 33 SIZE_MOBILE = (380, 640) |
34 account_1_cookies = None | 34 accounts_cookies = {} |
35 | 35 |
36 | 36 |
37 @pytest.hookimpl(tryfirst=True, hookwrapper=True) | 37 @pytest.hookimpl(tryfirst=True, hookwrapper=True) |
38 def pytest_runtest_makereport(item, call): | 38 def pytest_runtest_makereport(item, call): |
39 # needed to get test results in request fixture | 39 # needed to get test results in request fixture |
90 | 90 |
91 @pytest.fixture | 91 @pytest.fixture |
92 def nobody_logged_in(browser): | 92 def nobody_logged_in(browser): |
93 browser.get_driver().delete_all_cookies() | 93 browser.get_driver().delete_all_cookies() |
94 | 94 |
95 def log_in(browser, account): | |
96 try: | |
97 account_cookies = accounts_cookies[account] | |
98 except KeyError: | |
99 browser.get_driver().delete_all_cookies() | |
100 browser.go_to("https://libervia.test:8443/login") | |
101 browser.write(account, into="login") | |
102 browser.write("test", into="password") | |
103 browser.click("log in") | |
104 accounts_cookies[account] = browser.get_driver().get_cookies()[0] | |
105 else: | |
106 browser.get_driver().add_cookie(account_cookies) | |
95 | 107 |
96 @pytest.fixture | 108 @pytest.fixture |
97 def log_in_account1(browser): | 109 def log_in_account1(browser): |
98 global account_1_cookies | 110 log_in(browser, "account1") |
99 if account_1_cookies is None: | |
100 browser.get_driver().delete_all_cookies() | |
101 browser.go_to("https://libervia.test:8443/login") | |
102 browser.write("account1", into="login") | |
103 browser.write("test", into="password") | |
104 browser.click("log in") | |
105 account_1_cookies = browser.get_driver().get_cookies() | |
106 else: | |
107 browser.get_driver().add_cookie(account_1_cookies) | |
108 | 111 |
112 @pytest.fixture | |
113 def log_in_account1_s2(browser): | |
114 log_in(browser, "account1_s2") | |
109 | 115 |
110 @pytest.fixture | 116 @pytest.fixture |
111 def mobile_screen(browser): | 117 def mobile_screen(browser): |
112 browser.get_driver().set_window_size(*SIZE_MOBILE) | 118 browser.get_driver().set_window_size(*SIZE_MOBILE) |
113 | 119 |