From bc0b692cbac1609914d4caef063690571d780b16 Mon Sep 17 00:00:00 2001 From: docktermj Date: Thu, 3 Oct 2024 17:26:36 -0400 Subject: [PATCH] #75 Savepoint --- src/senzing_abstract/szengine_abstract.py | 37 +++++++++++++++++++++-- tests/szengine_test.py | 15 ++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/senzing_abstract/szengine_abstract.py b/src/senzing_abstract/szengine_abstract.py index fa5506a..bc1618d 100644 --- a/src/senzing_abstract/szengine_abstract.py +++ b/src/senzing_abstract/szengine_abstract.py @@ -85,12 +85,13 @@ class SzEngineAbstract(ABC): 4030: PREFIX + "search_by_attributes({0}) failed. Return code: {1}", 4031: PREFIX + "why_entities({0}, {1}) failed. Return code: {2}", 4032: PREFIX + "why_records({0}, {1}, {2}, {3}, {4}) failed. Return code: {5}", - 4033: PREFIX + "why_record_in_entity{0}, {1}, {2}) failed. Return code: {3}", + 4033: PREFIX + "why_record_in_entity({0}, {1}, {2}) failed. Return code: {3}", 4034: ( PREFIX + "SzEngine({0}, {1}) failed. instance_name and settings must both be set or" " both be empty" ), + 4035: PREFIX + "preprocess_record({0}, {1}) failed. Return code: {2}", } """ :meta private: """ @@ -114,7 +115,7 @@ def add_record( Args: data_source_code (str): Identifies the provenance of the data. record_id (str): The unique identifier within the records of the same data source. - record_definition (str | Dict): A JSON document containing the record to be added to the Senzing repository. + record_definition (str): A JSON document containing the record to be added to the Senzing repository. flags (int, optional): Flags used to control information returned. Defaults to 0. Returns: @@ -754,6 +755,38 @@ def how_entity_by_entity_id( :language: json """ + @abstractmethod + def preprocess_record( + self, + record_definition: str, + flags: int = 0, + **kwargs: Any, + ) -> str: + """ + The `preprocess_record` method tests adding a record into the Senzing datastore. + + Args: + record_definition (str): A JSON document containing the record to be added to the Senzing repository. + flags (int, optional): Flags used to control information returned. Defaults to 0. + + Returns: + str: A JSON document containing metadata as specified by the flags. + + Raises: + + .. collapse:: Example: + + .. literalinclude:: ../../examples/szengine/preprocess_record.py + :linenos: + :language: python + + **Output:** + + .. literalinclude:: ../../examples/szengine/preprocess_record.txt + :linenos: + :language: json + """ + @abstractmethod def prime_engine(self, **kwargs: Any) -> None: """ diff --git a/tests/szengine_test.py b/tests/szengine_test.py index a41a61a..3a6a920 100644 --- a/tests/szengine_test.py +++ b/tests/szengine_test.py @@ -130,6 +130,11 @@ def test_how_entity_by_entity_id(sz_engine: SzEngineAbstract) -> None: # sz_engine.initialize("", "") +def test_preprocess_record(sz_engine: SzEngineAbstract) -> None: + """Test SzEngine().preprocess_record().""" + sz_engine.preprocess_record("", 0) + + def test_prime_engine(sz_engine: SzEngineAbstract) -> None: """Test SzEngine().prime_engine().""" sz_engine.prime_engine() @@ -202,7 +207,7 @@ def add_record( self, data_source_code: str, record_id: str, - record_definition: Union[str, Dict[Any, Any]], + record_definition: str, flags: int = 0, **kwargs: Any, ) -> str: @@ -361,6 +366,14 @@ def initialize( ) -> None: """None""" + def preprocess_record( + self, + record_definition: str, + flags: int = 0, + **kwargs: Any, + ) -> str: + return "" + def prime_engine(self, **kwargs: Any) -> None: """None"""