def test_stbt_control_relay(stbt_control_relay_on_path): # pylint: disable=unused-argument with named_temporary_directory("stbt-control-relay-test.XXXXXX") as tmpdir: def t(filename): return os.path.join(tmpdir, filename) proc = subprocess.Popen([ "stbt-control-relay", "--socket", t("lircd.sock"), "file:" + t("one-file") ]) with scoped_process(proc): wait_until(lambda: (os.path.exists(t("lircd.sock")) or proc.poll() is not None)) testcontrol = uri_to_control("lirc:%s:stbt-test" % t("lircd.sock")) testcontrol.press("KEY_LEFT") testcontrol.press("KEY_RIGHT") testcontrol.keydown("KEY_MENU") testcontrol.keyup("KEY_MENU") expected = dedent("""\ KEY_LEFT KEY_RIGHT Holding KEY_MENU Released KEY_MENU """) assert expected == open(t("one-file")).read()
def test_stbt_control_relay(stbt_control_relay_on_path): # pylint: disable=unused-argument with named_temporary_directory("stbt-control-relay-test.XXXXXX") as tmpdir: def t(filename): return os.path.join(tmpdir, filename) proc = subprocess.Popen( ["stbt-control-relay", "--socket", t("lircd.sock"), "file:" + t("one-file")]) with scoped_process(proc): wait_until(lambda: ( os.path.exists(t("lircd.sock")) or proc.poll() is not None)) testcontrol = uri_to_control("lirc:%s:stbt-test" % t("lircd.sock")) testcontrol.press("KEY_LEFT") testcontrol.press("KEY_RIGHT") testcontrol.keydown("KEY_MENU") testcontrol.keyup("KEY_MENU") expected = dedent("""\ KEY_LEFT KEY_RIGHT Holding KEY_MENU Released KEY_MENU """) assert expected == open(t("one-file")).read()
def test_stbt_control_relay(stbt_control_relay_on_path): # pylint: disable=unused-argument with named_temporary_directory("stbt-control-relay-test.XXXXXX") as tmpdir: def t(filename): return os.path.join(tmpdir, filename) proc = subprocess.Popen( ["stbt-control-relay", "--input=lircd:" + t("lircd.sock"), "file:" + t("one-file"), "file:" + t("another")]) with scoped_process(proc): wait_until(lambda: ( os.path.exists(t("lircd.sock")) or proc.poll() is not None)) testremote = uri_to_remote("lirc:%s:stbt" % t("lircd.sock")) testremote.press("KEY_UP") testremote.press("KEY_DOWN") expected = "KEY_UP\nKEY_DOWN\n" def filecontains(filename, text): try: with open(t(filename)) as f: return text == f.read() except OSError: return None wait_until(lambda: ( filecontains("one-file", expected) and filecontains("another", expected))) assert open(t("one-file")).read() == expected assert open(t("another")).read() == expected
def test_stbt_control_relay(stbt_control_relay_on_path): # pylint: disable=unused-argument with named_temporary_directory("stbt-control-relay-test.XXXXXX") as tmpdir: def t(filename): return os.path.join(tmpdir, filename) proc = subprocess.Popen( ["stbt-control-relay", "--socket", t("lircd.sock"), "file:" + t("one-file")]) with scoped_process(proc): wait_until(lambda: ( os.path.exists(t("lircd.sock")) or proc.poll() is not None)) testremote = uri_to_remote("lirc:%s:stbt" % t("lircd.sock")) testremote.press("KEY_UP") testremote.press("KEY_DOWN") expected = "KEY_UP\nKEY_DOWN\n" assert open(t("one-file")).read() == expected