From abbbcf52c1680f4d082f721384d7083c0da309d1 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 23 Jan 2018 14:45:15 +0100 Subject: [PATCH] add missing session_stats_header_alert in python binding --- bindings/python/src/alert.cpp | 4 ++++ bindings/python/test.py | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 382b38599..4739c16ec 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -954,6 +954,10 @@ void bind_alert() .add_property("values", &session_stats_values) ; + class_, noncopyable>( + "session_stats_header_alert", no_init) + ; + std::vector (dht_get_peers_reply_alert::*peers)() const = &dht_get_peers_reply_alert::peers; class_, noncopyable>( diff --git a/bindings/python/test.py b/bindings/python/test.py index 2db229bb1..ea288e377 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -496,20 +496,21 @@ class test_session(unittest.TestCase): self.assertEqual(s.get_settings()['user_agent'], 'test123') def test_post_session_stats(self): - s = lt.session(settings) + s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False}) s.post_session_stats() alerts = [] # first the stats headers log line. but not if logging is disabled - if 'log_alert' in [i[0] for i in inspect.getmembers(lt)]: - s.wait_for_alert(1000) - alerts = s.pop_alerts() - a = alerts.pop(0) - self.assertTrue(isinstance(a, lt.log_alert)) + s.wait_for_alert(1000) + alerts = s.pop_alerts() + a = alerts.pop(0) + print(a) + self.assertTrue(isinstance(a, lt.session_stats_header_alert)) # then the actual stats values if len(alerts) == 0: s.wait_for_alert(1000) alerts = s.pop_alerts() a = alerts.pop(0) + print(a) self.assertTrue(isinstance(a, lt.session_stats_alert)) self.assertTrue(isinstance(a.values, dict)) self.assertTrue(len(a.values) > 0)