Coverage for heritrace / uri_generator / uri_generator.py: 82%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-07-02 10:16 +0000

1# SPDX-FileCopyrightText: 2024-2025 Arcangelo Massari <arcangelo.massari@unibo.it> 

2# 

3# SPDX-License-Identifier: ISC 

4 

5from __future__ import annotations 

6 

7from abc import ABC, abstractmethod 

8from typing import TYPE_CHECKING, Protocol, runtime_checkable 

9 

10if TYPE_CHECKING: 

11 from rdflib_ocdm.counter_handler.counter_handler import CounterHandler 

12 

13 from heritrace.sparql import SPARQLWrapperWithRetry 

14 

15 

16class URIGenerator(ABC): # pragma: no cover 

17 @abstractmethod 

18 def generate_uri( 

19 self, entity_type: str | None = None, context_data: dict | None = None 

20 ) -> str: 

21 pass 

22 

23 @abstractmethod 

24 def initialize_counters(self, sparql: SPARQLWrapperWithRetry) -> None: 

25 pass 

26 

27 

28@runtime_checkable 

29class CounterBasedURIGenerator(Protocol): 

30 @property 

31 def counter_handler(self) -> CounterHandler: ... 

32 

33 def initialize_counters(self, sparql: SPARQLWrapperWithRetry) -> None: ...