@@ -60,7 +60,7 @@ def valid_ipv4(ip: str) -> bool: # pylint: disable=C0103
60
60
return False
61
61
62
62
for i in arr :
63
- if int (i ) < 0 and int (i ) > 255 :
63
+ if int (i ) < 0 or int (i ) > 255 :
64
64
return False
65
65
66
66
return True
@@ -121,6 +121,15 @@ def __init__(self, data: dict) -> None:
121
121
self .pass_file = data ["pass_file" ] if "pass_file" in data else self .PASSWORD_FILE
122
122
self .user_file = data ["user_file" ] if "user_file" in data else self .USERS_FILE
123
123
124
+ def __eq__ (self , other : "ContainerFormatConfig" ):
125
+ """
126
+ Equality magic method used for testing this class
127
+
128
+ :param other: Another ContainerFormatConfig object to check if they're the same
129
+ """
130
+ variables = ("format" , "image_type" , "image" , "url" , "config" , "config_dir" , "pfile" , "pass_file" , "user_file" )
131
+ return all (getattr (self , attr ) == getattr (other , attr ) for attr in variables )
132
+
124
133
def get_format (self ) -> str :
125
134
"""Getter method to get the container format"""
126
135
return self .format
@@ -208,6 +217,15 @@ def __init__(self, data: dict) -> None:
208
217
self .stop_command = data ["stop_command" ] if "stop_command" in data else self .STOP_COMMAND
209
218
self .pull_command = data ["pull_command" ] if "pull_command" in data else self .PULL_COMMAND
210
219
220
+ def __eq__ (self , other : "ContainerFormatConfig" ):
221
+ """
222
+ Equality magic method used for testing this class
223
+
224
+ :param other: Another ContainerFormatConfig object to check if they're the same
225
+ """
226
+ variables = ("command" , "run_command" , "stop_command" , "pull_command" )
227
+ return all (getattr (self , attr ) == getattr (other , attr ) for attr in variables )
228
+
211
229
def get_command (self ) -> str :
212
230
"""Getter method to get the container command"""
213
231
return self .command
@@ -242,6 +260,15 @@ def __init__(self, data: dict) -> None:
242
260
self .status = data ["status" ] if "status" in data else self .STATUS_COMMAND
243
261
self .kill = data ["kill" ] if "kill" in data else self .KILL_COMMAND
244
262
263
+ def __eq__ (self , other : "ProcessConfig" ):
264
+ """
265
+ Equality magic method used for testing this class
266
+
267
+ :param other: Another ProcessConfig object to check if they're the same
268
+ """
269
+ variables = ("status" , "kill" )
270
+ return all (getattr (self , attr ) == getattr (other , attr ) for attr in variables )
271
+
245
272
def get_status_command (self ) -> str :
246
273
"""Getter method to get the status command"""
247
274
return self .status
@@ -264,12 +291,10 @@ class ServerConfig: # pylint: disable=R0903
264
291
container_format : ContainerFormatConfig = None
265
292
266
293
def __init__ (self , data : dict ) -> None :
267
- if "container" in data :
268
- self .container = ContainerConfig (data ["container" ])
269
- if "process" in data :
270
- self .process = ProcessConfig (data ["process" ])
271
- if self .container .get_format () in data :
272
- self .container_format = ContainerFormatConfig (data [self .container .get_format ()])
294
+ self .container = ContainerConfig (data ["container" ]) if "container" in data else None
295
+ self .process = ProcessConfig (data ["process" ]) if "process" in data else None
296
+ container_format_data = data .get (self .container .get_format () if self .container else None )
297
+ self .container_format = ContainerFormatConfig (container_format_data ) if container_format_data else None
273
298
274
299
275
300
class RedisConfig :
0 commit comments