@@ -77,47 +77,135 @@ def test_format_dict_value_to_string(self):
7777 sfputil .QSFP_DOM_CHANNEL_MONITOR_MAP ,
7878 sfputil .DOM_VALUE_UNIT_MAP )
7979 assert output == expected_output
80-
81- def test_convert_sfp_info_to_output_string (self ):
82- sfp_info_dict = {
83- 'type' : 'QSFP28 or later' ,
84- 'type_abbrv_name' : 'QSFP28' ,
85- 'manufacturer' : 'Mellanox' ,
86- 'model' : 'MCP1600-C003' ,
87- 'vendor_rev' : 'A2' ,
88- 'serial' : 'MT1636VS10561' ,
89- 'vendor_oui' : '00-02-c9' ,
90- 'vendor_date' : '2016-07-18' ,
91- 'connector' : 'No separable connector' ,
92- 'encoding' : '64B66B' ,
93- 'ext_identifier' : 'Power Class 1(1.5W max)' ,
94- 'ext_rateselect_compliance' : 'QSFP+ Rate Select Version 1' ,
95- 'cable_type' : 'Length Cable Assembly(m)' ,
96- 'cable_length' : '3' ,
97- 'application_advertisement' : 'N/A' ,
98- 'specification_compliance' : "{'10/40G Ethernet Compliance Code': '40GBASE-CR4'}" ,
99- 'dom_capability' : "{'Tx_power_support': 'no', 'Rx_power_support': 'no', 'Voltage_support': 'no', 'Temp_support': 'no'}" ,
100- 'nominal_bit_rate' : '255'
101- }
102-
103- expected_output = '''\
104- Application Advertisement: N/A
105- Connector: No separable connector
106- Encoding: 64B66B
107- Extended Identifier: Power Class 1(1.5W max)
108- Extended RateSelect Compliance: QSFP+ Rate Select Version 1
109- Identifier: QSFP28 or later
110- Length Cable Assembly(m): 3
111- Nominal Bit Rate(100Mbs): 255
112- Specification compliance:
113- 10/40G Ethernet Compliance Code: 40GBASE-CR4
114- Vendor Date Code(YYYY-MM-DD Lot): 2016-07-18
115- Vendor Name: Mellanox
116- Vendor OUI: 00-02-c9
117- Vendor PN: MCP1600-C003
118- Vendor Rev: A2
119- Vendor SN: MT1636VS10561
120- '''
80+ @pytest .mark .parametrize ("sfp_info_dict, expected_output" ,[
81+ # Non-CMIS module
82+ (
83+ # sfp_info_dict
84+ {
85+ 'type' : 'QSFP28 or later' ,
86+ 'type_abbrv_name' : 'QSFP28' ,
87+ 'manufacturer' : 'Mellanox' ,
88+ 'model' : 'MCP1600-C003' ,
89+ 'vendor_rev' : 'A2' ,
90+ 'serial' : 'MT1636VS10561' ,
91+ 'vendor_oui' : '00-02-c9' ,
92+ 'vendor_date' : '2016-07-18' ,
93+ 'connector' : 'No separable connector' ,
94+ 'encoding' : '64B66B' ,
95+ 'ext_identifier' : 'Power Class 1(1.5W max)' ,
96+ 'ext_rateselect_compliance' : 'QSFP+ Rate Select Version 1' ,
97+ 'cable_type' : 'Length Cable Assembly(m)' ,
98+ 'cable_length' : '3' ,
99+ 'application_advertisement' : 'N/A' ,
100+ 'specification_compliance' : "{'10/40G Ethernet Compliance Code': '40GBASE-CR4'}" ,
101+ 'dom_capability' : "{'Tx_power_support': 'no', 'Rx_power_support': 'no', 'Voltage_support': 'no', 'Temp_support': 'no'}" ,
102+ 'nominal_bit_rate' : '255'
103+ },
104+ # expected_output
105+ " Application Advertisement: N/A\n "
106+ " Connector: No separable connector\n "
107+ " Encoding: 64B66B\n "
108+ " Extended Identifier: Power Class 1(1.5W max)\n "
109+ " Extended RateSelect Compliance: QSFP+ Rate Select Version 1\n "
110+ " Identifier: QSFP28 or later\n "
111+ " Length Cable Assembly(m): 3\n "
112+ " Nominal Bit Rate(100Mbs): 255\n "
113+ " Specification compliance:\n "
114+ " 10/40G Ethernet Compliance Code: 40GBASE-CR4\n "
115+ " Vendor Date Code(YYYY-MM-DD Lot): 2016-07-18\n "
116+ " Vendor Name: Mellanox\n "
117+ " Vendor OUI: 00-02-c9\n "
118+ " Vendor PN: MCP1600-C003\n "
119+ " Vendor Rev: A2\n "
120+ " Vendor SN: MT1636VS10561\n "
121+ ),
122+ # CMIS compliant module
123+ (
124+ # sfp_info_dict
125+ {
126+ 'type' : 'QSFP-DD Double Density 8X Pluggable Transceiver' ,
127+ 'type_abbrv_name' : 'QSFP-DD' ,
128+ 'manufacturer' : 'abc' ,
129+ 'model' : 'def' ,
130+ 'vendor_rev' : 'ghi' ,
131+ 'serial' : 'jkl' ,
132+ 'vendor_oui' : '00-00-00' ,
133+ 'vendor_date' : '2000-01-01' ,
134+ 'connector' : 'LC' ,
135+ 'encoding' : 'N/A' ,
136+ 'ext_identifier' : 'Power Class 8 (18.0W Max)' ,
137+ 'ext_rateselect_compliance' : 'N/A' ,
138+ 'cable_type' : 'Length Cable Assembly(m)' ,
139+ 'cable_length' : '0' ,
140+ 'application_advertisement' : 'N/A' ,
141+ 'specification_compliance' : "sm_media_interface" ,
142+ 'dom_capability' : "{'Tx_power_support': 'no', 'Rx_power_support': 'no', 'Voltage_support': 'no', 'Temp_support': 'no'}" ,
143+ 'nominal_bit_rate' : '0' ,
144+ 'active_firmware' : '0.1' ,
145+ 'inactive_firmware' : '0.0' ,
146+ 'hardware_rev' : '0.0' ,
147+ 'media_interface_code' : '400ZR, DWDM, amplified' ,
148+ 'host_electrical_interface' : '400GAUI-8 C2M (Annex 120E)' ,
149+ 'host_lane_count' : 8 ,
150+ 'media_lane_count' : 1 ,
151+ 'host_lane_assignment_option' : 1 ,
152+ 'media_lane_assignment_option' : 1 ,
153+ 'active_apsel_hostlane1' : 1 ,
154+ 'active_apsel_hostlane2' : 1 ,
155+ 'active_apsel_hostlane3' : 1 ,
156+ 'active_apsel_hostlane4' : 1 ,
157+ 'active_apsel_hostlane5' : 1 ,
158+ 'active_apsel_hostlane6' : 1 ,
159+ 'active_apsel_hostlane7' : 1 ,
160+ 'active_apsel_hostlane8' : 1 ,
161+ 'media_interface_technology' : 'C-band tunable laser' ,
162+ 'cmis_rev' : '5.0' ,
163+ 'supported_max_tx_power' : 0 ,
164+ 'supported_min_tx_power' : - 20 ,
165+ 'supported_max_laser_freq' : 196100 ,
166+ 'supported_min_laser_freq' : 191300
167+ },
168+ # expected_output
169+ " Active App Selection Host Lane 1: 1\n "
170+ " Active App Selection Host Lane 2: 1\n "
171+ " Active App Selection Host Lane 3: 1\n "
172+ " Active App Selection Host Lane 4: 1\n "
173+ " Active App Selection Host Lane 5: 1\n "
174+ " Active App Selection Host Lane 6: 1\n "
175+ " Active App Selection Host Lane 7: 1\n "
176+ " Active App Selection Host Lane 8: 1\n "
177+ " Active Firmware Version: 0.1\n "
178+ " CMIS Revision: 5.0\n "
179+ " Connector: LC\n "
180+ " Encoding: N/A\n "
181+ " Extended Identifier: Power Class 8 (18.0W Max)\n "
182+ " Extended RateSelect Compliance: N/A\n "
183+ " Hardware Revision: 0.0\n "
184+ " Host Electrical Interface: 400GAUI-8 C2M (Annex 120E)\n "
185+ " Host Lane Assignment Options: 1\n "
186+ " Host Lane Count: 8\n "
187+ " Identifier: QSFP-DD Double Density 8X Pluggable Transceiver\n "
188+ " Inactive Firmware Version: 0.0\n "
189+ " Length Cable Assembly(m): 0\n "
190+ " Media Interface Code: 400ZR, DWDM, amplified\n "
191+ " Media Interface Technology: C-band tunable laser\n "
192+ " Media Lane Assignment Options: 1\n "
193+ " Media Lane Count: 1\n "
194+ " Nominal Bit Rate(100Mbs): 0\n "
195+ " Specification compliance: sm_media_interface\n "
196+ " Supported Max Laser Frequency: 196100GHz\n "
197+ " Supported Max TX Power: 0dBm\n "
198+ " Supported Min Laser Frequency: 191300GHz\n "
199+ " Supported Min TX Power: -20dBm\n "
200+ " Vendor Date Code(YYYY-MM-DD Lot): 2000-01-01\n "
201+ " Vendor Name: abc\n "
202+ " Vendor OUI: 00-00-00\n "
203+ " Vendor PN: def\n "
204+ " Vendor Rev: ghi\n "
205+ " Vendor SN: jkl\n "
206+ ),
207+ ])
208+ def test_convert_sfp_info_to_output_string (self , sfp_info_dict , expected_output ):
121209 output = sfputil .convert_sfp_info_to_output_string (sfp_info_dict )
122210 assert output == expected_output
123211
0 commit comments