Skip to content

Commit

Permalink
updated xml response for recovery timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vilnitsky committed Aug 30, 2022
1 parent ebcd11f commit 5b5acfe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 38 deletions.
2 changes: 1 addition & 1 deletion fake_switches/juniper/juniper_netconf_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def ethernet_switching_to_etree(self, port, interface_data):
if len(vlans) > 0:
ethernet_switching["vlan"] = [{"members": str(v)} for v in vlans]
if port.recovery_timeout is not None:
ethernet_switching["recovery-timeout"] = port.recovery_timeout
ethernet_switching["recovery-timeout"] = {"time-in-seconds": port.recovery_timeout}
if ethernet_switching or not isinstance(port, AggregatedPort):
interface_data.append({"unit": {
"name": "0",
Expand Down
40 changes: 3 additions & 37 deletions tests/juniper/juniper_base_protocol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ def test_that_recovery_timeout_can_be_configured(self):
"port-mode": "trunk"}}}]}]}]})
self.nc.commit()
get_interface_reply = self._interface('ae1')
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout")[0].text, equal_to("500"))
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout/time-in-seconds")[0].text, equal_to("500"))
self.cleanup(reset_interface("ae1"))

def test_that_recovery_timeout_can_be_updated(self):
Expand All @@ -1759,7 +1759,7 @@ def test_that_recovery_timeout_can_be_updated(self):
"port-mode": "trunk"}}}]}]}]})
self.nc.commit()
get_interface_reply = self._interface('ae1')
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout")[0].text, equal_to("500"))
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout/time-in-seconds")[0].text, equal_to("500"))

self.edit({
"interfaces": [
Expand All @@ -1772,44 +1772,10 @@ def test_that_recovery_timeout_can_be_updated(self):
"recovery-timeout": "300"}}}]}]}]})
self.nc.commit()
get_interface_reply = self._interface('ae1')
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout")[0].text, equal_to("300"))
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout/time-in-seconds")[0].text, equal_to("300"))

self.cleanup(reset_interface("ae1"))

def test_that_recovery_timeout_can_be_deleted(self):
self.edit({
"interfaces": [
{"interface": [
{"name": "ae1"},
{"aggregated-ether-options": {
"link-speed": "10g",
"lacp": {
"active": {},
"periodic": "slow"}}},
{"unit": [
{"name": "0"},
{"family": {
"ethernet-switching": {
"recovery-timeout": "500",
"port-mode": "trunk"}}}]}]}]})
self.nc.commit()
get_interface_reply = self._interface('ae1')
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching/recovery-timeout")[0].text, equal_to("500"))

self.edit({
"interfaces": [
{"interface": [
{"name": "ae1"},
{"unit": [
{"name": "0"},
{"family": {
"ethernet-switching": {
"recovery-timeout": "delete"}}}]}]}]})
self.nc.commit()
get_interface_reply = self._interface('ae1')
assert_that(get_interface_reply.xpath("unit/family/ethernet-switching"), has_length(1))

self.cleanup(reset_interface("ae1"))

def _interface(self, name):
result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": {
Expand Down

0 comments on commit 5b5acfe

Please sign in to comment.