add missing session_stats_header_alert in python binding

This commit is contained in:
arvidn 2018-01-23 14:45:15 +01:00 committed by Arvid Norberg
parent a8cf790833
commit abbbcf52c1
2 changed files with 11 additions and 6 deletions

View File

@ -954,6 +954,10 @@ void bind_alert()
.add_property("values", &session_stats_values)
;
class_<session_stats_header_alert, bases<alert>, noncopyable>(
"session_stats_header_alert", no_init)
;
std::vector<tcp::endpoint> (dht_get_peers_reply_alert::*peers)() const = &dht_get_peers_reply_alert::peers;
class_<dht_get_peers_reply_alert, bases<alert>, noncopyable>(

View File

@ -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)