sonic-buildimage/dockers/docker-dhcp-relay/cli-plugin-tests/conftest.py
Yaqiang Zhu bb48ee92ab
[dhcp-relay] Add support for dhcp_relay config cli (#13373)
Why I did it
Currently the config cli of dhcpv4 is may cause confusion and config of dhcpv6 is missing.

How I did it
Add dhcp_relay config cli and test cases.

config dhcp_relay ipv4 helper (add | del) <vlan_id> <helper_ip_list>
config dhcp_relay ipv6 destination (add | del) <vlan_id> <destination_ip_list>
Updated docs for it in sonic-utilities: https://github.com/sonic-net/sonic-utilities/pull/2598/files
How to verify it
Build docker-dhcp-relay.gz with and without INCLUDE_DHCP_RELAY, and check target/docker-dhcp-relay.gz.log
2023-01-30 17:48:01 -08:00

33 lines
716 B
Python

import pytest
import mock_tables # lgtm [py/unused-import]
from unittest import mock
@pytest.fixture()
def mock_cfgdb():
cfgdb = mock.Mock()
CONFIG = {
'VLAN': {
'Vlan1000': {
'dhcp_servers': ['192.0.0.1']
}
},
'DHCP_RELAY': {
'Vlan1000': {
'dhcpv6_servers': ['fc02:2000::1']
}
}
}
def get_entry(table, key):
return CONFIG[table][key]
def set_entry(table, key, data):
CONFIG[table].setdefault(key, {})
CONFIG[table][key] = data
cfgdb.get_entry = mock.Mock(side_effect=get_entry)
cfgdb.set_entry = mock.Mock(side_effect=set_entry)
yield cfgdb