test_playback.py (1700B)
1 import os 2 import time 3 4 import mozinfo 5 import mozunit 6 from mozlog.structuredlog import StructuredLogger, set_default_logger 7 8 # need this so raptor imports work both from /raptor and via mach 9 here = os.path.abspath(os.path.dirname(__file__)) 10 11 set_default_logger(StructuredLogger("test_playback")) 12 13 14 from mozproxy import get_playback 15 from mozproxy.backends.mitm.desktop import MitmproxyDesktop 16 17 config = {} 18 19 run_local = True 20 if os.environ.get("TOOLTOOLCACHE") is None: 21 run_local = False 22 23 24 def test_get_playback(get_binary): 25 config["platform"] = mozinfo.os 26 if "win" in config["platform"]: 27 # this test is not yet supported on windows 28 assert True 29 return 30 config["obj_path"] = os.path.dirname(get_binary("firefox")) 31 config["playback_tool"] = "mitmproxy" 32 config["playback_version"] = "8.1.1" 33 config["playback_files"] = [ 34 os.path.join( 35 os.path.dirname(os.path.abspath(os.path.dirname(__file__))), 36 "raptor", 37 "tooltool-manifests", 38 "playback", 39 "mitm8-linux-firefox-amazon.manifest", 40 ) 41 ] 42 config["binary"] = get_binary("firefox") 43 config["run_local"] = run_local 44 config["app"] = "firefox" 45 config["host"] = "127.0.0.1" 46 47 playback = get_playback(config) 48 assert isinstance(playback, MitmproxyDesktop) 49 playback.start() 50 time.sleep(1) 51 playback.stop() 52 53 54 def test_get_unsupported_playback(): 55 config["playback_tool"] = "unsupported" 56 playback = get_playback(config) 57 assert playback is None 58 59 60 def test_get_playback_missing_tool_name(): 61 playback = get_playback(config) 62 assert playback is None 63 64 65 if __name__ == "__main__": 66 mozunit.main()