feat: add tox test for static format check via black/flake8, integration test
This commit is contained in:
parent
fbd24a13c0
commit
b3f624a119
|
@ -127,3 +127,6 @@ dmypy.json
|
||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
|
# patched chromedriver
|
||||||
|
chromedriver
|
|
@ -0,0 +1,33 @@
|
||||||
|
import pytest
|
||||||
|
from _pytest.fixtures import FixtureRequest
|
||||||
|
import undetected_chromedriver as uc
|
||||||
|
|
||||||
|
FAILED_SCREENSHOT_NAME = "failed.png"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def head_uc(request: FixtureRequest):
|
||||||
|
request.instance.driver = uc.Chrome()
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
request.instance.driver.save_screenshot(FAILED_SCREENSHOT_NAME)
|
||||||
|
request.instance.driver.quit()
|
||||||
|
|
||||||
|
request.addfinalizer(teardown)
|
||||||
|
|
||||||
|
return request.instance.driver
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def headless_uc(request: FixtureRequest):
|
||||||
|
options = uc.ChromeOptions()
|
||||||
|
options.headless = True
|
||||||
|
request.instance.driver = uc.Chrome(options=options)
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
request.instance.driver.save_screenshot(FAILED_SCREENSHOT_NAME)
|
||||||
|
request.instance.driver.quit()
|
||||||
|
|
||||||
|
request.addfinalizer(teardown)
|
||||||
|
|
||||||
|
return request.instance.driver
|
|
@ -0,0 +1,20 @@
|
||||||
|
import pytest
|
||||||
|
from selenium.webdriver.remote.webdriver import WebDriver
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
|
||||||
|
|
||||||
|
TIMEOUT = 10
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("head_uc")
|
||||||
|
class TestBotCheck:
|
||||||
|
def test_bot_protect_io(self):
|
||||||
|
driver: WebDriver = self.driver # type: ignore
|
||||||
|
driver.get("https://lhcdn.botprotect.io")
|
||||||
|
msg = WebDriverWait(driver, TIMEOUT).until(
|
||||||
|
EC.visibility_of_element_located((By.ID, "msg"))
|
||||||
|
)
|
||||||
|
print(msg.text)
|
||||||
|
assert "You are human." in msg.text
|
|
@ -0,0 +1,34 @@
|
||||||
|
[tox]
|
||||||
|
envlist =
|
||||||
|
py38,
|
||||||
|
static_check,
|
||||||
|
v1,
|
||||||
|
v2
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
deps =
|
||||||
|
pytest
|
||||||
|
selenium
|
||||||
|
|
||||||
|
[testenv:static_check]
|
||||||
|
deps =
|
||||||
|
black
|
||||||
|
flake8
|
||||||
|
commands =
|
||||||
|
black --check --diff .
|
||||||
|
flake8 undetected_chromedriver \
|
||||||
|
--max-line-length=88 \
|
||||||
|
--exclude v2.py
|
||||||
|
|
||||||
|
[testenv:v1]
|
||||||
|
commands =
|
||||||
|
pytest \
|
||||||
|
-v -s \
|
||||||
|
./tests/v1
|
||||||
|
|
||||||
|
; Currently v2 is WIP
|
||||||
|
; [testenv:v2]
|
||||||
|
; commands =
|
||||||
|
; pytest \
|
||||||
|
; -v -s \
|
||||||
|
; ./tests/v2
|
Loading…
Reference in New Issue