diff --git a/api/sip/__init__.py b/api/sip/__init__.py index 07788a2014..e42bb96b21 100644 --- a/api/sip/__init__.py +++ b/api/sip/__init__.py @@ -120,6 +120,7 @@ class SIP2Settings(BasicAuthProviderSettings): options={ Sip2Dialect.GENERIC_ILS: "Generic ILS", Sip2Dialect.AG_VERSO: "Auto-Graphics VERSO", + Sip2Dialect.FOLIO: "Folio", }, required=True, ), diff --git a/api/sip/client.py b/api/sip/client.py index 7bfd53f9f3..8a2317db77 100644 --- a/api/sip/client.py +++ b/api/sip/client.py @@ -372,7 +372,7 @@ def patron_information(self, *args, **kwargs): def end_session(self, *args, **kwargs): """Send end session message.""" - if self.dialect_config.sendEndSession: + if self.dialect_config.send_end_session: return self.make_request( self.end_session_message, self.end_session_response_parser, @@ -842,8 +842,10 @@ def parse_patron_status(cls, status_string): def now(self): """Return the current time, formatted as SIP expects it.""" + tz_spaces = self.dialect_config.tz_spaces now = utc_now() - return datetime.datetime.strftime(now, "%Y%m%d0000%H%M%S") + zzzz = " " * 4 if tz_spaces else "0" * 4 + return datetime.datetime.strftime(now, f"%Y%m%d{zzzz}%H%M%S") def summary( self, diff --git a/api/sip/dialect.py b/api/sip/dialect.py index a962a35076..bb8b5829e7 100644 --- a/api/sip/dialect.py +++ b/api/sip/dialect.py @@ -6,19 +6,23 @@ class DialectConfig: """Describe a SIP2 dialect_config.""" - sendEndSession: bool + send_end_session: bool + tz_spaces: bool class Dialect(Enum): GENERIC_ILS = "GenericILS" AG_VERSO = "AutoGraphicsVerso" + FOLIO = "TZSpaces" @property def config(self) -> DialectConfig: """Return the configuration for this dialect.""" if self == Dialect.GENERIC_ILS: - return DialectConfig(sendEndSession=True) + return DialectConfig(send_end_session=True, tz_spaces=False) elif self == Dialect.AG_VERSO: - return DialectConfig(sendEndSession=False) + return DialectConfig(send_end_session=False, tz_spaces=False) + elif self == Dialect.FOLIO: + return DialectConfig(send_end_session=True, tz_spaces=True) else: raise NotImplementedError(f"Unknown dialect: {self}") diff --git a/tests/api/sip/test_client.py b/tests/api/sip/test_client.py index aefeb00ebe..2153165249 100644 --- a/tests/api/sip/test_client.py +++ b/tests/api/sip/test_client.py @@ -708,12 +708,13 @@ def test_parse_patron_status(self): class TestClientDialects: @pytest.mark.parametrize( - "dialect,expected_read_count,expected_write_count", + "dialect,expected_read_count,expected_write_count,expected_tz_spaces", [ # Generic ILS should send end_session message - (Dialect.GENERIC_ILS, 1, 1), + (Dialect.GENERIC_ILS, 1, 1, False), # AG VERSO ILS shouldn't end_session message - (Dialect.AG_VERSO, 0, 0), + (Dialect.AG_VERSO, 0, 0, False), + (Dialect.FOLIO, 1, 1, True), ], ) def test_dialect( @@ -722,6 +723,7 @@ def test_dialect( dialect, expected_read_count, expected_write_count, + expected_tz_spaces, ): sip = sip_client_factory(dialect=dialect) sip.queue_response("36Y201610210000142637AO3|AA25891000331441|AF|AG") @@ -729,3 +731,9 @@ def test_dialect( assert sip.dialect_config == dialect.config assert sip.read_count == expected_read_count assert sip.write_count == expected_write_count + assert sip.dialect_config.tz_spaces == expected_tz_spaces + + # verify timestamp format aligns with the expected tz spaces dialect + ts = sip.now() + tz_element = ts[8:12] + assert tz_element == (" " if expected_tz_spaces else "0000")