Skip to content

Commit

Permalink
Ensure that stored port numbers are ints
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Oct 18, 2023
1 parent bdb9ba6 commit 2df751e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/zinolib/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UserConfig(BaseModel):

class ServerV1Config(BaseModel):
server: str
port: str = "8001"
port: int = 8001


class Options(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions src/zinolib/config/zino1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions tests/test_zinolib_config_zino1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_parse_tcl_golden_path(self):
},
}
expected_connection = {
"port": "8001",
"port": 8001,
"password": "0123456789",
"server": "example.org",
"username": "admin",
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2df751e

Please sign in to comment.