diff --git a/tests/test_defaults.py b/tests/test_defaults.py index 4413deb3..40d962b8 100644 --- a/tests/test_defaults.py +++ b/tests/test_defaults.py @@ -1,112 +1,106 @@ def test_defaults(api): defaults = { - 'flows': [ + "flows": [ { - 'tx_rx': { - 'choice': 'port', - 'port': { - 'tx_name': 'ptest', - } - }, - 'name': "f1", - 'size': { - 'choice': 'fixed', - 'fixed': 64 - }, - 'rate': { - 'choice': 'pps', # default choice is pps - 'pps': "1000" + "tx_rx": { + "choice": "port", + "port": { + "tx_name": "ptest", + }, }, - 'packet': [ + "name": "f1", + "size": {"choice": "fixed", "fixed": 64}, + "rate": {"choice": "pps", "pps": "1000"}, # default choice is pps + "packet": [ { - 'choice': 'ethernet', - 'ethernet': { - 'dst': { - 'choice': 'auto', - 'auto': '00:00:00:00:00:00', + "choice": "ethernet", + "ethernet": { + "dst": { + "choice": "auto", + "auto": "00:00:00:00:00:00", }, - 'src': { - 'choice': 'values', - 'values': ['00:00:00:00:00:00'], + "src": { + "choice": "values", + "values": ["00:00:00:00:00:00"], + }, + "ether_type": { + "auto": 65535, + "choice": "auto", }, - 'ether_type': { - 'auto': 65535, - 'choice': 'auto', - } }, }, { - 'choice': 'ipv4', - 'ipv4': { - 'src': { - 'choice': 'increment', - 'increment': { - 'count': 1, - 'start': '0.0.0.0', - 'step': '0.0.0.1' + "choice": "ipv4", + "ipv4": { + "src": { + "choice": "increment", + "increment": { + "count": 1, + "start": "0.0.0.0", + "step": "0.0.0.1", }, } - } - - } - ] + }, + }, + ], } ], - 'lags': [ + "lags": [ { - 'name': "abc", - 'protocol': { - 'choice': 'lacp', # default choice is lacp - 'lacp': { - 'actor_key': 0, - 'actor_system_id': '00:00:00:00:00:00', - 'actor_system_priority': 0, - } + "name": "abc", + "protocol": { + "choice": "lacp", # default choice is lacp + "lacp": { + "actor_key": 0, + "actor_system_id": "00:00:00:00:00:00", + "actor_system_priority": 0, + }, }, - 'ports': [ + "ports": [ { - 'port_name': 'lagport', - 'lacp': { - 'actor_activity': 'active', - 'actor_port_number': 0, - 'actor_port_priority': 1, - 'lacpdu_periodic_time_interval': 0, - 'lacpdu_timeout': 0 + "port_name": "lagport", + "lacp": { + "actor_activity": "active", + "actor_port_number": 0, + "actor_port_priority": 1, + "lacpdu_periodic_time_interval": 0, + "lacpdu_timeout": 0, + }, + "ethernet": { + "mac": "00:00:00:00:00:00", + "mtu": 1500, + "name": "test", }, - 'ethernet': { - 'mac': '00:00:00:00:00:00', 'mtu': 1500, 'name': 'test' - } } ], - "min_links": 1 + "min_links": 1, } ], - 'layer1': [ + "layer1": [ { - 'auto_negotiate': True, - 'ieee_media_defaults': True, - 'mtu': 1500, - 'name': "abc", - 'port_names': ["test"], - 'promiscuous': True, - 'speed': 'speed_10_gbps', - 'flow_control': { - 'choice': 'ieee_802_1qbb', - 'directed_address': '01:80:C2:00:00:01', - 'ieee_802_1qbb': { - 'pfc_class_0': 0, - 'pfc_class_1': 1, - 'pfc_class_2': 2, - 'pfc_class_3': 3, - 'pfc_class_4': 4, - 'pfc_class_5': 5, - 'pfc_class_6': 6, - 'pfc_class_7': 7, - 'pfc_delay': 0 - } - } + "auto_negotiate": True, + "ieee_media_defaults": True, + "mtu": 1500, + "name": "abc", + "port_names": ["test"], + "promiscuous": True, + "flow_control": { + "choice": "ieee_802_1qbb", + "directed_address": "01:80:C2:00:00:01", + "ieee_802_1qbb": { + "pfc_class_0": 0, + "pfc_class_1": 1, + "pfc_class_2": 2, + "pfc_class_3": 3, + "pfc_class_4": 4, + "pfc_class_5": 5, + "pfc_class_6": 6, + "pfc_class_7": 7, + "pfc_delay": 0, + }, + }, } - ] + ], } config = api.config() layer1 = config.layer1.layer1()[-1] @@ -138,76 +132,66 @@ def test_defaults(api): def test_defaults_by_deserialize(api): defaults = { - 'flows': [ + "flows": [ { - 'tx_rx': { - 'choice': 'port', - 'port': { - 'tx_name': 'ptest', - 'rx_name': None - } - }, - 'name': "f1", - 'size': { - 'choice': 'fixed', - 'fixed': 64 + "tx_rx": { + "choice": "port", + "port": {"tx_name": "ptest", "rx_name": None}, }, - 'rate': { - 'choice': 'pps', - 'pps': None # defaults to a value - } + "name": "f1", + "size": {"choice": "fixed", "fixed": 64}, + "rate": {"choice": "pps", "pps": None}, # defaults to a value } ], - 'lags': [ + "lags": [ { - 'name': "abc", - 'protocol': { - 'choice': 'lacp', # default choice is lacp - 'lacp': { - 'actor_key': 0, - 'actor_system_id': '00:00:00:00:00:00', - 'actor_system_priority': 0, - } + "name": "abc", + "protocol": { + "choice": "lacp", # default choice is lacp + "lacp": { + "actor_key": 0, + "actor_system_id": "00:00:00:00:00:00", + "actor_system_priority": 0, + }, }, - 'ports': [ + "ports": [ { - 'port_name': 'lagport', - 'lacp': { - 'actor_activity': 'active', - 'actor_port_number': None, #default is 0 - 'actor_port_priority': 1, - 'lacpdu_periodic_time_interval': 0, - 'lacpdu_timeout': 0 + "port_name": "lagport", + "lacp": { + "actor_activity": "active", + "actor_port_number": None, # default is 0 + "actor_port_priority": 1, + "lacpdu_periodic_time_interval": 0, + "lacpdu_timeout": 0, + }, + "ethernet": { + "mac": "00:00:00:00:00:00", + "mtu": 1500, + "name": "test", }, - 'ethernet': { - 'mac': '00:00:00:00:00:00', 'mtu': 1500, 'name': 'test' - } } ], - "min_links": 1 + "min_links": 1, } ], - 'layer1': [ + "layer1": [ { - 'auto_negotiate': True, - 'ieee_media_defaults': True, - 'mtu': 1500, - 'name': "abc", - 'port_names': ["test"], - 'promiscuous': True, - 'speed': 'speed_10_gbps', - 'flow_control': { - 'directed_address': '01:80:C2:00:00:01' - } + "auto_negotiate": True, + "ieee_media_defaults": True, + "mtu": 1500, + "name": "abc", + "port_names": ["test"], + "promiscuous": True, + "flow_control": {"directed_address": "01:80:C2:00:00:01"}, } - ] + ], } config = api.config() config.deserialize(defaults) assert config.layer1[0].mtu == 1500 - assert config.layer1[0].flow_control.directed_address == '01:80:C2:00:00:01' - assert config.lags[0].protocol.choice == 'lacp' + assert config.layer1[0].flow_control.directed_address == "01:80:C2:00:00:01" + assert config.lags[0].protocol.choice == "lacp" assert config.lags[0].ports[0].lacp.actor_port_number == 0 assert config.lags[0].ports[0].lacp.actor_port_priority == 1 - assert config.lags[0].protocol.lacp.actor_system_id == '00:00:00:00:00:00' + assert config.lags[0].protocol.lacp.actor_system_id == "00:00:00:00:00:00"