A TrafficAnalyzer with side-effecting init paths stubbed out. We don't want the constructor probing real network interfaces or running `ip`/tcpdump during unit tests.
()
| 18 | |
| 19 | @pytest.fixture |
| 20 | def analyzer(): |
| 21 | """A TrafficAnalyzer with side-effecting init paths stubbed out. |
| 22 | |
| 23 | We don't want the constructor probing real network interfaces or running |
| 24 | `ip`/tcpdump during unit tests. |
| 25 | """ |
| 26 | with patch.object(TrafficAnalyzer, '_detect_interface', return_value='lo'), \ |
| 27 | patch.object(TrafficAnalyzer, '_detect_local_ips', |
| 28 | return_value={'127.0.0.1', '192.168.1.10'}): |
| 29 | a = TrafficAnalyzer(shared_data=None, interface='lo') |
| 30 | # Make alert rate-limiting essentially unlimited for tests. |
| 31 | a.MAX_ALERTS_PER_MINUTE = 10_000 |
| 32 | a._alert_dedup_window = 0 |
| 33 | return a |
| 34 | |
| 35 | |
| 36 | def _seed_periodic_flow(analyzer, src, dst, port, *, |
nothing calls this directly
no test coverage detected