Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pybird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def _parse_peer_summary(self, line):
state = None
up = None

raw_datetime = elements[4]
raw_datetime = f"{elements[4]} {elements[5]}"
last_change = self._calculate_datetime(raw_datetime)

return {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/commands/show_protocols_all/000.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"export_updates_received": 0, "protocol": "BGP", "description": "Peering AS8954 - InTouch", "import_updates_ignored": 0, "import_withdraws_rejected": 0, "export_updates_accepted": 0, "import_updates_accepted": 0, "import_updates_received": 0, "export_updates_filtered": 0, "import_withdraws_ignored": 0, "routes_imported": 0, "export_updates_rejected": 0, "import_updates_filtered": 0, "export_withdraws_accepted": 0, "import_withdraws_accepted": 0, "export_withdraws_received": 0, "up": false, "name": "PS1", "state": "Passive", "routes_exported": 0, "import_updates_rejected": 0, "last_change": "2010-06-29T00:00:00", "import_withdraws_received": 0}, {"router_id": "85.184.4.5", "export_updates_received": 12, "protocol": "BGP", "description": "Peering AS8954 - InTouch", "import_updates_ignored": 0, "import_withdraws_rejected": 0, "export_updates_accepted": 0, "import_updates_accepted": 12, "import_updates_received": 12, "export_updates_filtered": 0, "address": "2001:7f8:1::a500:8954:1", "import_withdraws_ignored": 0, "routes_imported": 24, "source": "2001:7f8:1::a519:7754:1", "asn": "8954", "export_updates_rejected": 12, "import_updates_filtered": 0, "export_withdraws_accepted": 0, "import_withdraws_accepted": 3, "export_withdraws_received": 3, "up": true, "name": "PS2", "state": "Established", "routes_exported": 23, "import_updates_rejected": 0, "last_change": "2010-06-29T00:00:00", "import_withdraws_received": 3}]
[{"export_updates_received": 0, "protocol": "BGP", "description": "Peering AS8954 - InTouch", "import_updates_ignored": 0, "import_withdraws_rejected": 0, "export_updates_accepted": 0, "import_updates_accepted": 0, "import_updates_received": 0, "export_updates_filtered": 0, "import_withdraws_ignored": 0, "routes_imported": 0, "export_updates_rejected": 0, "import_updates_filtered": 0, "export_withdraws_accepted": 0, "import_withdraws_accepted": 0, "export_withdraws_received": 0, "up": false, "name": "PS1", "state": "Passive", "routes_exported": 0, "import_updates_rejected": 0, "last_change": "2010-06-29T09:12:27", "import_withdraws_received": 0}, {"router_id": "85.184.4.5", "export_updates_received": 12, "protocol": "BGP", "description": "Peering AS8954 - InTouch", "import_updates_ignored": 0, "import_withdraws_rejected": 0, "export_updates_accepted": 0, "import_updates_accepted": 12, "import_updates_received": 12, "export_updates_filtered": 0, "address": "2001:7f8:1::a500:8954:1", "import_withdraws_ignored": 0, "routes_imported": 24, "source": "2001:7f8:1::a519:7754:1", "asn": "8954", "export_updates_rejected": 12, "import_updates_filtered": 0, "export_withdraws_accepted": 0, "import_withdraws_accepted": 3, "export_withdraws_received": 3, "up": true, "name": "PS2", "state": "Established", "routes_exported": 23, "import_updates_rejected": 0, "last_change": "2010-06-29T09:12:27", "import_withdraws_received": 3}]
12 changes: 6 additions & 6 deletions tests/data/commands/show_protocols_all/000.input
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

0001 BIRD 1.3.0 ready.
2002-name proto table state since info
1002-device1 Device master up 2010-06-29
2002-name proto table state since info
1002-device1 Device master up 2010-06-29 09:12:27
1006- Preference: 240
Input filter: ACCEPT
Output filter: REJECT
Expand All @@ -12,7 +12,7 @@
Export updates: 0 0 0 --- 0
Export withdraws: 0 --- --- --- 0

1002-P_PS1 Pipe master up 2010-06-29 => T_PS1
1002-P_PS1 Pipe master up 2010-06-29 09:12:27 => T_PS1
1006- Preference: 70
Input filter: <NULL>
Output filter: <NULL>
Expand All @@ -23,7 +23,7 @@
Export updates: 0 0 0 0 0
Export withdraws: 0 0 --- 0 0

1002-PS1 BGP T_PS1 start 2010-06-29 Passive
1002-PS1 BGP T_PS1 start 2010-06-29 09:12:27 Passive
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand All @@ -36,7 +36,7 @@
Export withdraws: 0 --- --- --- 0
BGP state: Passive

1002-P_PS2 Pipe master up 2010-06-29 => T_PS2
1002-P_PS2 Pipe master up 2010-06-29 09:12:27 => T_PS2
1006- Preference: 70
Input filter: <NULL>
Output filter: <NULL>
Expand All @@ -47,7 +47,7 @@
Export updates: 0 0 0 0 0
Export withdraws: 0 0 --- 0 0

1002-PS2 BGP T_PS2 start 2010-06-29 Established
1002-PS2 BGP T_PS2 start 2010-06-29 09:12:27 Established
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand Down
4 changes: 2 additions & 2 deletions tests/data/commands/show_protocols_all_"PS1"/000.input
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0001 BIRD 1.3.0 ready.
2002-name proto table state since info
1002-PS1 BGP T_PS1 start 2010-06-29 Passive
2002-name proto table state since info
1002-PS1 BGP T_PS1 start 2010-06-29 09:12:27 Passive
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand Down
4 changes: 2 additions & 2 deletions tests/data/commands/show_protocols_all_"PS2"/000.input
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0001 BIRD 1.3.0 ready.
2002-name proto table state since info
1002-PS2 BGP T_PS2 up 2010-06-29 Established
2002-name proto table state since info
1002-PS2 BGP T_PS2 up 2010-06-29 09:12:27 Established
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand Down
16 changes: 8 additions & 8 deletions tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_specific_peer_status(self):
for correctness."""
ps2_status = self.pybird.get_peer_status("PS2")
assert ps2_status["up"]
assert ps2_status["last_change"] == datetime(2010, 6, 29)
assert ps2_status["last_change"] == datetime(2010, 6, 29, 9, 12, 27)
assert ps2_status["state"] == "Established"
assert ps2_status["routes_imported"] == 24
assert ps2_status["routes_exported"] == 23
Expand All @@ -134,7 +134,7 @@ def test_specific_peer_status(self):
ps1_status = self.pybird.get_peer_status("PS1")
self.assertFalse(ps1_status["up"])

assert ps1_status["last_change"] == datetime(2010, 6, 29)
assert ps1_status["last_change"] == datetime(2010, 6, 29, 9, 12, 27)
assert ps1_status["state"] == "Passive"

def test_specific_peer_prefixes_announced(self):
Expand Down Expand Up @@ -219,8 +219,8 @@ def test_show_protocols_all_mocked_correctly(self):
data
== """
0001 BIRD 1.3.0 ready.
2002-name proto table state since info
1002-device1 Device master up 2010-06-29
2002-name proto table state since info
1002-device1 Device master up 2010-06-29 09:12:27
1006- Preference: 240
Input filter: ACCEPT
Output filter: REJECT
Expand All @@ -231,7 +231,7 @@ def test_show_protocols_all_mocked_correctly(self):
Export updates: 0 0 0 --- 0
Export withdraws: 0 --- --- --- 0

1002-P_PS1 Pipe master up 2010-06-29 => T_PS1
1002-P_PS1 Pipe master up 2010-06-29 09:12:27 => T_PS1
1006- Preference: 70
Input filter: <NULL>
Output filter: <NULL>
Expand All @@ -242,7 +242,7 @@ def test_show_protocols_all_mocked_correctly(self):
Export updates: 0 0 0 0 0
Export withdraws: 0 0 --- 0 0

1002-PS1 BGP T_PS1 start 2010-06-29 Passive
1002-PS1 BGP T_PS1 start 2010-06-29 09:12:27 Passive
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand All @@ -255,7 +255,7 @@ def test_show_protocols_all_mocked_correctly(self):
Export withdraws: 0 --- --- --- 0
BGP state: Passive

1002-P_PS2 Pipe master up 2010-06-29 => T_PS2
1002-P_PS2 Pipe master up 2010-06-29 09:12:27 => T_PS2
1006- Preference: 70
Input filter: <NULL>
Output filter: <NULL>
Expand All @@ -266,7 +266,7 @@ def test_show_protocols_all_mocked_correctly(self):
Export updates: 0 0 0 0 0
Export withdraws: 0 0 --- 0 0

1002-PS2 BGP T_PS2 start 2010-06-29 Established
1002-PS2 BGP T_PS2 start 2010-06-29 09:12:27 Established
1006- Description: Peering AS8954 - InTouch
Preference: 100
Input filter: ACCEPT
Expand Down
Loading