MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_signals

Function test_signals

test/mitmproxy/addons/test_view.py:482–535  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

480
481
482def test_signals():
483 v = view.View()
484 rec_add = Record()
485 rec_update = Record()
486 rec_remove = Record()
487 rec_refresh = Record()
488
489 def clearrec():
490 rec_add.calls = []
491 rec_update.calls = []
492 rec_remove.calls = []
493 rec_refresh.calls = []
494
495 v.sig_view_add.connect(rec_add)
496 v.sig_view_update.connect(rec_update)
497 v.sig_view_remove.connect(rec_remove)
498 v.sig_view_refresh.connect(rec_refresh)
499
500 assert not any([rec_add, rec_update, rec_remove, rec_refresh])
501
502 # Simple add
503 v.add([tft()])
504 assert rec_add
505 assert not any([rec_update, rec_remove, rec_refresh])
506
507 # Filter change triggers refresh
508 clearrec()
509 v.set_filter(flowfilter.parse("~m put"))
510 assert rec_refresh
511 assert not any([rec_update, rec_add, rec_remove])
512
513 v.set_filter(flowfilter.parse("~m get"))
514
515 # An update that results in a flow being added to the view
516 clearrec()
517 v[0].request.method = "PUT"
518 v.update([v[0]])
519 assert rec_remove
520 assert not any([rec_update, rec_refresh, rec_add])
521
522 # An update that does not affect the view just sends update
523 v.set_filter(flowfilter.parse("~m put"))
524 clearrec()
525 v.update([v[0]])
526 assert rec_update
527 assert not any([rec_remove, rec_refresh, rec_add])
528
529 # An update for a flow in state but not view does not do anything
530 f = v[0]
531 v.set_filter(flowfilter.parse("~m get"))
532 assert not len(v)
533 clearrec()
534 v.update([f])
535 assert not any([rec_add, rec_update, rec_remove, rec_refresh])
536
537
538def test_focus_follow():

Callers

nothing calls this directly

Calls 8

addMethod · 0.95
set_filterMethod · 0.95
updateMethod · 0.95
RecordClass · 0.85
tftFunction · 0.85
clearrecFunction · 0.85
connectMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…