Chapter 07 — ocarina-example, the canonical suite

Chapter 07 — ocarina-example#

E2E suite designed to test Igoristan. The reference example: every Ocarina project starts by reading this repo and copying its adapters.

Outline#

#FileTopic
0101-tree.mdThe full src/ tree: pages/, lib/, api/, caches/, constants/, tests/.
0202-adapters.mdThe 5 adapters (act, match_page, TestSuite, TestCampaign, EnvGetters).
0303-scenarios-login.mdDashboard login scenarios: happy / unhappy / data-driven.
0404-scenarios-corsicamon.mdCorsicamon scenarios: api_key, draw, add, back.
0505-scenarios-randomness.mdRandomness scenarios (4 levels): random_error, random_loaders, dsed, madness, chaotic_form, walkthrough.
0606-scenarios-sacred-upload.mdSacred upload scenarios: upload_files, back_to_igoristan.
0707-humanized-driver.mdHumanizedDriver: Selenium proxy to simulate human typing.
0808-caches-locks.mdL1 cache (dogpile.cache.memory) + reserved keys + distributed Redis locks.
0909-watcher-catch-me.mdThe catch_me_if_you_can watcher for the chaotic form.
1010-env-getters.mdEnvGetters[_CredsKeys, _ValuesKeys] strictly typed via Literal.
1111-ci.mdCI: main_ci.yml + dev_ci.yml (lint+typecheck) + e2e.yml (Redis + manual Firefox).

Goal#

Holy Book quote (chapter “First steps”):

02.12 — Custom types & custom errors

02.12 — Custom types & custom errors#

Ocarina’s shape layer. No logic — types, aliases, exceptions, protocols. What makes the DSL typed without adding runtime logic.

custom_types/#

FileContents
effect.pytype Effect = Callable[[], None] + type Effects = tuple[Effect, ...]
thunk.pytype Thunk[T] = Callable[[], T]
tpom.pyTypeVar TPOM bound POMBase
supports_write.pyProtocol SupportsWrite[T] (write(s: T) -> Any)
built_web_driver.pytype BuiltWebDriver[Driver] = tuple[Driver, Effect]
scenario.pyScenario[Driver] (frozen dataclass)
test_components.pyTestChain, TestSetup, TestTeardown, TestWatchers[Driver]
test_runner.pyTestRunner[Driver] (frozen dataclass)
oc_test.pyTestName, TestScenario[Driver], TestScenarioFragment[Driver]
oc_test_layers.pyTestId, TestResult, TestSuiteResult, TestSuiteResults, TestCampaignResults, TestCycleResults
selenium/built_web_driver.pyBuiltSeleniumWebDriver = BuiltWebDriver[WebDriver]
selenium/oc_test_scenario.pySeleniumTestScenario = TestScenario[WebDriver]
selenium/supported_browsers.pytype SupportedSeleniumBrowser = Literal["chrome", "firefox", "edge", "safari"]
selenium/web_drivers_pool.pytype SeleniumWebDriversPool = WebDriversPool[WebDriver]

All these files are excluded from coverage (pyproject.toml#tool.coverage):