Skip to content

Commit

Permalink
ruff findings, exclude protocol definitions from code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
deichmab-draeger committed Nov 21, 2024
1 parent 2e637a4 commit e0cfc41
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 122 deletions.
8 changes: 4 additions & 4 deletions src/sdc11073/mdib/entityprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sdc11073.xml_types.pm_types import CodedValue, Coding


class EntityProtocol(Protocol):
class EntityProtocol(Protocol): # pragma: no cover
"""The protocol defines the interface of single-state entities."""

descriptor: AbstractDescriptorProtocol
Expand All @@ -36,7 +36,7 @@ def update(self):
"""Update entity with current mdib data."""


class MultiStateEntityProtocol(Protocol):
class MultiStateEntityProtocol(Protocol): # pragma: no cover
"""The protocol defines the interface of multi-state entities."""

descriptor: AbstractDescriptorProtocol
Expand All @@ -57,7 +57,7 @@ def new_state(self, handle: str | None = None) -> AbstractMultiStateProtocol:

# Todo: should node_type be QName (this assumes that we talk XML) or just Any to be generic?

class EntityGetterProtocol(Protocol):
class EntityGetterProtocol(Protocol): # pragma: no cover
"""The protocol defines a way to access mdib data as entities.
This representation is independent of the internal mdib organization.
Expand Down Expand Up @@ -99,7 +99,7 @@ def __len__(self) -> int:
...


class ProviderEntityGetterProtocol(EntityGetterProtocol):
class ProviderEntityGetterProtocol(EntityGetterProtocol): # pragma: no cover
"""The protocol adds the new_entity method to EntityGetterProtocol."""

def new_entity(self,
Expand Down
2 changes: 1 addition & 1 deletion src/sdc11073/mdib/mdibprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)


class ProviderMdibProtocol(Protocol):
class ProviderMdibProtocol(Protocol): # pragma: no cover
"""The interface of a provider mdib.
This interface only expects the ProviderEntityGetterProtocol.
Expand Down
18 changes: 9 additions & 9 deletions src/sdc11073/mdib/transactionsprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TransactionType(Enum):
rt_sample = 7


class TransactionResultProtocol(Protocol):
class TransactionResultProtocol(Protocol): # pragma: no cover
"""TransactionResult contains all state and descriptors that were modified in the transaction.
The states and descriptors are used to create the notification(s) that keep the consumers up to date.
Expand All @@ -52,7 +52,7 @@ class TransactionResultProtocol(Protocol):
def all_states(self) -> list[AbstractStateProtocol]:
"""Return all states in this transaction."""

class TransactionItemProtocol(Protocol):
class TransactionItemProtocol(Protocol): # pragma: no cover
"""A container for the old and the new version of a state or descriptor.
If old is None, this is an object that is added to mdib.
Expand All @@ -74,7 +74,7 @@ class TransactionItem:



class AbstractTransactionManagerProtocol(Protocol):
class AbstractTransactionManagerProtocol(Protocol): # pragma: no cover
"""Interface of a TransactionManager."""

new_mdib_version: int
Expand All @@ -93,7 +93,7 @@ def process_transaction(self, set_determination_time: bool) -> TransactionResult
error: bool


class EntityDescriptorTransactionManagerProtocol(AbstractTransactionManagerProtocol):
class EntityDescriptorTransactionManagerProtocol(AbstractTransactionManagerProtocol): # pragma: no cover
"""Entity based transaction manager for modification of descriptors (and associated states).
The entity based transaction manager protocol can only be used with EntityGetter methods!
Expand Down Expand Up @@ -128,7 +128,7 @@ def remove_entity(self, entity: EntityTypeProtocol):
"""Remove existing descriptor from mdib."""


class EntityStateTransactionManagerProtocol(AbstractTransactionManagerProtocol):
class EntityStateTransactionManagerProtocol(AbstractTransactionManagerProtocol): # pragma: no cover
"""Entity based transaction manager for modification of states.
The entity based transaction manager protocol can only be used with EntityGetter methods!
Expand All @@ -153,7 +153,7 @@ def write_entities(self,
"""Update the states of entities."""


class EntityContextStateTransactionManagerProtocol(AbstractTransactionManagerProtocol):
class EntityContextStateTransactionManagerProtocol(AbstractTransactionManagerProtocol): # pragma: no cover
"""Entity based transaction manager for modification of context states.
The entity based transaction manager protocol can only be used with EntityGetter methods!
Expand All @@ -170,7 +170,7 @@ def write_entity(self, entity: MultiStateEntityProtocol,
"""Insert or update a context state in mdib."""


class DescriptorTransactionManagerProtocol(EntityDescriptorTransactionManagerProtocol):
class DescriptorTransactionManagerProtocol(EntityDescriptorTransactionManagerProtocol): # pragma: no cover
"""The classic Interface of a TransactionManager that modifies descriptors.
The classic transaction manager protocol can not be used with EntityGetter methods!
Expand Down Expand Up @@ -232,7 +232,7 @@ def mk_context_state(self, descriptor_handle: str,
"""Create a new ContextStateContainer."""


class StateTransactionManagerProtocol(EntityStateTransactionManagerProtocol):
class StateTransactionManagerProtocol(EntityStateTransactionManagerProtocol): # pragma: no cover
"""The classic Interface of a TransactionManager that modifies states (except context states).
The classic transaction manager protocol can not be used with EntityGetter methods!
Expand All @@ -257,7 +257,7 @@ def get_state(self, descriptor_handle: str) -> AbstractStateProtocol:
"""Read a state from mdib and add it to the transaction."""


class ContextStateTransactionManagerProtocol(EntityContextStateTransactionManagerProtocol):
class ContextStateTransactionManagerProtocol(EntityContextStateTransactionManagerProtocol): # pragma: no cover
"""The classic Interface of a TransactionManager that modifies context states.
The classic transaction manager protocol can not be used with EntityGetter methods!
Expand Down
6 changes: 3 additions & 3 deletions tests/test_entity_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class TestEntityTransactions(unittest.TestCase):
"""Test all kinds of transactions for entity interface of EntityProviderMdib."""

def setUp(self): # noqa: D102
def setUp(self):
self._mdib = EntityProviderMdib.from_mdib_file(mdib_file,
protocol_definition=SdcV1Definitions)

Expand Down Expand Up @@ -183,15 +183,15 @@ def test_remove_add(self):
"""Verify that removing descriptors / states and adding them later again results in correct versions."""
# remove all root descriptors
all_entities = {}
for handle in self._mdib._entities: # noqa: SLF001
for handle in self._mdib._entities:
all_entities[handle] = self._mdib.entities.handle(handle) # get external representation

root_entities = self._mdib.entities.parent_handle(None)
with self._mdib.descriptor_transaction() as mgr:
for ent in root_entities:
mgr.remove_entity(ent)

self.assertEqual(0, len(self._mdib._entities)) # noqa: SLF001
self.assertEqual(0, len(self._mdib._entities))

# add all entities again
with self._mdib.descriptor_transaction() as mgr:
Expand Down
Loading

0 comments on commit e0cfc41

Please sign in to comment.