-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ isort>=5.12.0 | |
pip-audit>=2.7.0 | ||
bandit>=1.7.5 | ||
licensecheck>=2024 | ||
requests>=2.32.2 | ||
selenium>=4.13.0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from selenium import webdriver as wd | ||
|
||
|
||
def chrome(): | ||
options = wd.ChromeOptions() | ||
options.add_argument("--headless=new") | ||
return wd.Chrome(options=options) | ||
|
||
|
||
def edge(): | ||
options = wd.EdgeOptions() | ||
options.add_argument("--headless=new") | ||
return wd.Edge(options=options) | ||
|
||
|
||
def firefox(): | ||
options = wd.FirefoxOptions() | ||
options.add_argument("-headless") | ||
return wd.Firefox(options=options) | ||
|
||
|
||
@pytest.fixture(params=[chrome, edge, firefox]) | ||
def driver(request): | ||
with request.param() as _driver: | ||
yield _driver |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,13 @@ | ||
import requests | ||
|
||
from webapp_python.main import RESPONSE_HEADERS | ||
from selenium.webdriver.remote.webdriver import BaseWebDriver | ||
|
||
from .server import get_server_url | ||
|
||
# TODO: Use selenium | ||
|
||
|
||
def test_main(): | ||
def test_main(driver: BaseWebDriver): | ||
with get_server_url() as webapp_url: | ||
response = requests.get(f"{webapp_url}", timeout=60) | ||
assert response.status_code == 200 | ||
for key, val in RESPONSE_HEADERS.items(): | ||
assert response.headers[key] == val | ||
assert "24/7 Bishops" in response.text | ||
response = requests.get(f"{webapp_url}/favicon.png?v=1729", timeout=60) | ||
assert response.status_code == 200 | ||
for key, val in RESPONSE_HEADERS.items(): | ||
assert response.headers[key] == val | ||
response = requests.get(f"{webapp_url}/css/main.css", timeout=60) | ||
assert response.status_code == 200 | ||
for key, val in RESPONSE_HEADERS.items(): | ||
assert response.headers[key] == val | ||
assert "background-color: green" in response.text | ||
driver.get(webapp_url) | ||
|
||
|
||
def test_maint(): | ||
def test_maint(driver: BaseWebDriver): | ||
with get_server_url(maintenance_mode=True) as webapp_url: | ||
response = requests.get(f"{webapp_url}", timeout=60) | ||
assert response.status_code == 503 | ||
assert "24/7 Bishops is Temporarily Unavailable" in response.text | ||
for key, val in RESPONSE_HEADERS.items(): | ||
assert response.headers[key] == val | ||
response = requests.post(f"{webapp_url}/random_path", timeout=60) | ||
assert response.status_code == 503 | ||
assert "24/7 Bishops is Temporarily Unavailable" in response.text | ||
for key, val in RESPONSE_HEADERS.items(): | ||
assert response.headers[key] == val | ||
driver.get(webapp_url) |
This file contains 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