mirror of
https://github.com/dw-0/kiauh.git
synced 2026-08-03 12:57:53 +05:00
test(extensions): add unit tests for base extension
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from extensions.base_extension import BaseExtension
|
||||||
|
|
||||||
|
|
||||||
|
class ConcreteExtension(BaseExtension):
|
||||||
|
def install_extension(self, **kwargs) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def remove_extension(self, **kwargs) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestBaseExtension:
|
||||||
|
def test_concrete_subclass_can_be_instantiated(self) -> None:
|
||||||
|
ext = ConcreteExtension({"name": "test"})
|
||||||
|
assert ext.metadata["name"] == "test"
|
||||||
|
|
||||||
|
def test_update_extension_not_implemented(self) -> None:
|
||||||
|
ext = ConcreteExtension({"name": "test"})
|
||||||
|
with pytest.raises(NotImplementedError):
|
||||||
|
ext.update_extension()
|
||||||
|
|
||||||
|
def test_abstract_methods_enforced(self) -> None:
|
||||||
|
class PartialExtension(BaseExtension):
|
||||||
|
def install_extension(self, **kwargs) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
PartialExtension({"name": "test"})
|
||||||
Reference in New Issue
Block a user