From 2df751e9c5c4a5180d2edc8df3d95da92a9ac6fd Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Wed, 18 Oct 2023 13:52:23 +0200 Subject: [PATCH] Ensure that stored port numbers are ints --- src/zinolib/config/models.py | 2 +- src/zinolib/config/zino1.py | 1 + tests/test_zinolib_config_zino1.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zinolib/config/models.py b/src/zinolib/config/models.py index db1e12e..a8d335f 100644 --- a/src/zinolib/config/models.py +++ b/src/zinolib/config/models.py @@ -8,7 +8,7 @@ class UserConfig(BaseModel): class ServerV1Config(BaseModel): server: str - port: str = "8001" + port: int = 8001 class Options(BaseModel): diff --git a/src/zinolib/config/zino1.py b/src/zinolib/config/zino1.py index 89d65b9..5804b72 100644 --- a/src/zinolib/config/zino1.py +++ b/src/zinolib/config/zino1.py @@ -9,6 +9,7 @@ def _parse_tcl(config_dict, section): connection = fixed_dict["connections"][section] options = fixed_dict["global_options"] connection['password'] = connection.pop("secret") + connection['port'] = int(connection.pop("port")) return connection, options diff --git a/tests/test_zinolib_config_zino1.py b/tests/test_zinolib_config_zino1.py index 27934b4..7c735eb 100644 --- a/tests/test_zinolib_config_zino1.py +++ b/tests/test_zinolib_config_zino1.py @@ -25,7 +25,7 @@ def test_parse_tcl_golden_path(self): }, } expected_connection = { - "port": "8001", + "port": 8001, "password": "0123456789", "server": "example.org", "username": "admin", @@ -54,7 +54,7 @@ def manually_create_config(self, connection=None): def test_manually_create_config(self): config = self.manually_create_config() - self.assertEqual(config.port, "8001") + self.assertEqual(config.port, 8001) def test_set_userauth(self): config = self.manually_create_config()