diff --git a/pybird/__init__.py b/pybird/__init__.py index 69d2c93..539b854 100644 --- a/pybird/__init__.py +++ b/pybird/__init__.py @@ -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 { diff --git a/tests/data/commands/show_protocols_all/000.expected b/tests/data/commands/show_protocols_all/000.expected index 4ddd53f..59a32e0 100644 --- a/tests/data/commands/show_protocols_all/000.expected +++ b/tests/data/commands/show_protocols_all/000.expected @@ -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}] diff --git a/tests/data/commands/show_protocols_all/000.input b/tests/data/commands/show_protocols_all/000.input index 52e8af1..3660801 100644 --- a/tests/data/commands/show_protocols_all/000.input +++ b/tests/data/commands/show_protocols_all/000.input @@ -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 @@ -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: Output filter: @@ -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 @@ -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: Output filter: @@ -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 diff --git "a/tests/data/commands/show_protocols_all_\"PS1\"/000.input" "b/tests/data/commands/show_protocols_all_\"PS1\"/000.input" index e850f2b..68d6a6b 100644 --- "a/tests/data/commands/show_protocols_all_\"PS1\"/000.input" +++ "b/tests/data/commands/show_protocols_all_\"PS1\"/000.input" @@ -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 diff --git "a/tests/data/commands/show_protocols_all_\"PS2\"/000.input" "b/tests/data/commands/show_protocols_all_\"PS2\"/000.input" index 6ff8496..9dc58c0 100644 --- "a/tests/data/commands/show_protocols_all_\"PS2\"/000.input" +++ "b/tests/data/commands/show_protocols_all_\"PS2\"/000.input" @@ -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 diff --git a/tests/test_socket.py b/tests/test_socket.py index ba55658..690ffdc 100644 --- a/tests/test_socket.py +++ b/tests/test_socket.py @@ -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 @@ -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): @@ -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 @@ -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: Output filter: @@ -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 @@ -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: Output filter: @@ -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