@@ -284,3 +284,69 @@ def test_conversion_utils_00050(value, expected, raises) -> None:
284284 match = f"Invalid MAC address: { str (value )} "
285285 with pytest .raises (ValueError , match = match ):
286286 instance .translate_mac_address (value )
287+
288+
289+ @pytest .mark .parametrize (
290+ "value, expected_exception" ,
291+ [
292+ ("validFabric" , None ), # valid fabric name
293+ ("ValidFabric123" , None ), # valid fabric name with numbers
294+ ("fabric_name" , None ), # valid fabric name with underscore
295+ ("fabric-name" , None ), # valid fabric name with dash
296+ ("a" , None ), # valid single letter
297+ ("A1_2-3" , None ), # valid with all allowed characters
298+ ("123fabric" , ValueError ), # invalid - starts with number
299+ ("_fabric" , ValueError ), # invalid - starts with underscore
300+ ("-fabric" , ValueError ), # invalid - starts with dash
301+ ("" , ValueError ), # invalid - empty string
302+ ("fabric@name" , ValueError ), # invalid - contains special character
303+ ("fabric name" , ValueError ), # invalid - contains space
304+ ("fabric.name" , ValueError ), # invalid - contains dot
305+ (123 , TypeError ), # invalid - not a string
306+ (None , TypeError ), # invalid - not a string
307+ (True , TypeError ), # invalid - not a string
308+ ([], TypeError ), # invalid - not a string
309+ ],
310+ )
311+ def test_conversion_utils_00060 (value , expected_exception ) -> None :
312+ """
313+ ### Classes and Methods
314+
315+ - ConversionUtils()
316+ - __init__()
317+ - validate_fabric_name()
318+
319+ ### Summary
320+
321+ - Verify valid fabric names pass validation
322+ - Verify TypeError is raised for non-string values
323+ - Verify ValueError is raised for invalid fabric name patterns
324+
325+ ### Setup
326+
327+ - ConversionUtils() is instantiated
328+
329+ ### Test
330+
331+ - `validate_fabric_name` is called with various values.
332+
333+ ### Expected Result
334+
335+ - No exception raised for valid fabric names
336+ - TypeError raised for non-string values
337+ - ValueError raised for invalid fabric name patterns
338+ """
339+ with does_not_raise ():
340+ instance = ConversionUtils ()
341+
342+ if expected_exception is None :
343+ with does_not_raise ():
344+ instance .validate_fabric_name (value )
345+ elif expected_exception == TypeError :
346+ match = f"Invalid fabric name. Expected string. Got { re .escape (str (value ))} ."
347+ with pytest .raises (TypeError , match = match ):
348+ instance .validate_fabric_name (value )
349+ elif expected_exception == ValueError :
350+ match = f"Invalid fabric name: { value } . Fabric name must start with a letter A-Z or a-z and contain only the characters in: \\ [A-Z,a-z,0-9,-,_\\ ]."
351+ with pytest .raises (ValueError , match = match ):
352+ instance .validate_fabric_name (value )
0 commit comments