initial commit
This commit is contained in:
parent
b84bd80842
commit
9411fe61ee
11 changed files with 272 additions and 1 deletions
20
src/tests_wordpress/conftest.py
Normal file
20
src/tests_wordpress/conftest.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from dotenv import dotenv_values
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--env_file_path",
|
||||
action="store",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config(request):
|
||||
dotenv_path = request.config.getoption("--env_file_path")
|
||||
dotenv_path = Path(dotenv_path)
|
||||
assert dotenv_path.is_file()
|
||||
config = dotenv_values(dotenv_path)
|
||||
return config
|
||||
29
src/tests_wordpress/test_wordpress.py
Normal file
29
src/tests_wordpress/test_wordpress.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import re
|
||||
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
def test_one():
|
||||
assert 1 + 1 == 2
|
||||
|
||||
|
||||
def test_two():
|
||||
assert 2 + 1 == 3
|
||||
|
||||
|
||||
def test_has_title(page: Page):
|
||||
page.goto("https://playwright.dev/")
|
||||
|
||||
# Expect a title "to contain" a substring.
|
||||
expect(page).to_have_title(re.compile("Playwright"))
|
||||
|
||||
|
||||
def test_get_started_link(page: Page):
|
||||
page.goto("https://playwright.dev/")
|
||||
|
||||
# Click the get started link.
|
||||
page.get_by_role("link", name="Get started").click()
|
||||
|
||||
# Expects page to have a heading with the name of Installation.
|
||||
expect(page.get_by_role("heading", name="Installation")).to_be_visible()
|
||||
26
src/tests_wordpress/test_wordpress_feature1.py
Normal file
26
src/tests_wordpress/test_wordpress_feature1.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import re
|
||||
|
||||
from icecream import ic
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
def test_one(config):
|
||||
ic(config)
|
||||
assert 1 + 1 == 2
|
||||
|
||||
|
||||
def test_has_title(page: Page):
|
||||
page.goto("https://playwright.dev/")
|
||||
|
||||
# Expect a title "to contain" a substring.
|
||||
expect(page).to_have_title(re.compile("Playwright"))
|
||||
|
||||
|
||||
def test_get_started_link(page: Page):
|
||||
page.goto("https://playwright.dev/")
|
||||
|
||||
# Click the get started link.
|
||||
page.get_by_role("link", name="Get started").click()
|
||||
|
||||
# Expects page to have a heading with the name of Installation.
|
||||
expect(page.get_by_role("heading", name="Installation")).to_be_visible()
|
||||
45
src/tests_wordpress/testrunner_wordpress.py
Normal file
45
src/tests_wordpress/testrunner_wordpress.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from dotenv import dotenv_values
|
||||
from icecream import ic
|
||||
|
||||
|
||||
class TestRunnerWordpress:
|
||||
def __init__(self, dotenv_path: Path):
|
||||
self.dotenv_path = dotenv_path
|
||||
self.show_files()
|
||||
self.load_dotenv()
|
||||
# self.run_pytest_dir_wp()
|
||||
# self.run_pytest_single_wp()
|
||||
self.run_pytest_single_wp_feature1()
|
||||
|
||||
def show_files(self):
|
||||
ic(list(self.root_dir.glob("*")))
|
||||
|
||||
def load_dotenv(self):
|
||||
dotenv_path = self.root_dir / "./blog.dev.local-it.cloud.env"
|
||||
assert dotenv_path.is_file()
|
||||
config = dotenv_values(dotenv_path)
|
||||
ic(config)
|
||||
|
||||
def run_pytest_dir_wp(self):
|
||||
pytest.main([self.root_dir / "tests_wordpress"])
|
||||
|
||||
def run_pytest_single_wp(self):
|
||||
pytest.main(
|
||||
[
|
||||
self.root_dir / "tests_wordpress" / "test_wordpress.py",
|
||||
"--env_file_path",
|
||||
self.dotenv_path,
|
||||
]
|
||||
)
|
||||
|
||||
def run_pytest_single_wp_feature1(self):
|
||||
pytest.main(
|
||||
[
|
||||
self.root_dir / "tests_wordpress" / "test_wordpress_feature1.py",
|
||||
"--env_file_path",
|
||||
self.dotenv_path,
|
||||
]
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue