19 lines
579 B
Python
19 lines
579 B
Python
import pytest
|
|
|
|
from docslib import HeaderButton
|
|
|
|
|
|
def test_header_button_validation_and_factories():
|
|
local = HeaderButton("Introduction", "1")
|
|
assert local.page == "1"
|
|
assert local.href is None
|
|
|
|
external = HeaderButton.external("GitHub", "https://github.com/")
|
|
assert external.href == "https://github.com/"
|
|
assert external.new_tab is True
|
|
|
|
with pytest.raises(ValueError, match="exactly one"):
|
|
HeaderButton("Broken")
|
|
|
|
with pytest.raises(ValueError, match="exactly one"):
|
|
HeaderButton("Broken", page="1", href="https://example.com")
|