def test_generate_profile(self): self.set_xrandr_mock("test/docked.txt") retval = main(["--config", "test/xprofilerc_both_example", "generate"]) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, "--verbose"]
def test_activate_profile_auto_select_and_non_existing(self): self.set_xrandr_mock('test/docked.txt', 'non-existing-edid') retval = main(['--config', 'test/xprofilerc_both_example', 'activate']) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, '--auto']
def test_generate_profile(self): self.set_xrandr_mock('test/docked.txt') retval = main(['--config', 'test/xprofilerc_both_example', 'generate']) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, '--verbose']
def test_current_profile(self): self.set_xrandr_mock("test/docked.txt", "c2989146488f57fa9dc5f7efc263b0fd1") retval = main(["--config", "test/xprofilerc_both_example", "current"]) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, "--verbose"]
def test_current_profile_does_not_exist(self): self.set_xrandr_mock('test/docked.txt', 'dkfjkdjfkdjfkdkfjd') retval = main(['--config', 'test/xprofilerc_both_example', 'current']) assert retval == 1 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, '--verbose']
def test_current_profile_does_not_exist(self): self.set_xrandr_mock("test/docked.txt", "dkfjkdjfkdjfkdkfjd") retval = main(["--config", "test/xprofilerc_both_example", "current"]) assert retval == 1 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, "--verbose"]
def test_activate_profile_auto_select_and_non_existing(self): self.set_xrandr_mock("test/docked.txt", "non-existing-edid") retval = main(["--config", "test/xprofilerc_both_example", "activate"]) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, "--auto"]
def test_activate_profile_auto_select_and_existing(self): self.set_xrandr_mock("test/docked.txt", "c2989146488f57fa9dc5f7efc263b0fd1") retval = main(["--config", "test/xprofilerc_both_example", "activate"]) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [ self.xrandr_bin, "--output", "LVDS1", "--off", "--output", "DP2", "--mode", "1920x1080", "--pos", "0x500", "--primary", "--output", "HDMI3", "--mode", "1920x1080", "--rotate", "left", "--pos", "1930x0", ]
def test_current_profile(self): self.set_xrandr_mock('test/docked.txt', 'c2989146488f57fa9dc5f7efc263b0fd1') retval = main(['--config', 'test/xprofilerc_both_example', 'current']) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [self.xrandr_bin, '--verbose']
def test_activate_profile_with_dry_run(self): self.set_xrandr_mock('test/docked.txt', 'c2989146488f57fa9dc5f7efc263b0fd1') retval = main([ '--config', 'test/xprofilerc_both_example', 'activate', '--dry-run' ]) assert retval == 0 assert self.xrandr.called
def test_activate_profile_non_existing(self): self.set_xrandr_mock('test/docked.txt') retval = main([ '--config', 'test/xprofilerc_both_example', 'activate', 'non-existing-profile' ]) assert retval == 1 assert not self.xrandr.called
def test_no_config_file(self): self.set_xrandr_mock("test/docked.txt") try: remove("test/non_existing_xprofilerc") except: pass retval = main(["--config", "test/non_existing_xprofilerc", "list"]) remove("test/non_existing_xprofilerc") assert retval == 0 assert not self.xrandr.called
def test_current(Popen): with open('test/docked.txt', 'rb') as file: xrandr_stdout = file.read() Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'current']) assert retval == 0 assert Popen.called
def test_no_config_file(self): self.set_xrandr_mock('test/docked.txt') try: remove('test/non_existing_xprofilerc') except: pass retval = main(['--config', 'test/non_existing_xprofilerc', 'list']) remove('test/non_existing_xprofilerc') assert retval == 0 assert not self.xrandr.called
def test_activate_profile_auto__dryrun(Popen): with open('test/laptop.txt', 'rb') as file: xrandr_stdout = file.read() Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'auto', '--dry-run']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--verbose']
def test_activate_profile_auto_nonexistent(Popen): with open('test/docked.txt', 'rb') as file: xrandr_stdout = file.read() Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'auto']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--auto']
def test_create_existing_profile(Popen): with open('test/docked.txt', 'rb') as file: xrandr_stdout = file.read() Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'create', 'laptop']) assert retval == 1 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--verbose']
def test_activate_profile_auto(Popen): with open('test/laptop.txt', 'rb') as file: xrandr_stdout = file.read() Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'auto']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--auto']
def test_create_new_profile(Popen): with open('test/docked.txt', 'rb') as file: xrandr_stdout = file.read() with tempfile.NamedTemporaryFile() as tmpfile: Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', tmpfile.name, 'create', 'testprofile']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--verbose']
def test_create_new_profile_dryrun(Popen): with open('test/docked.txt', 'rb') as file: xrandr_stdout = file.read() with tempfile.NamedTemporaryFile() as tmpfile: Popen.return_value.communicate.return_value = (xrandr_stdout, None) Popen.return_value.wait.return_value = 0 retval = main(['--config', tmpfile.name, 'create', 'testprofile', '--dry-run']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == ['/usr/bin/xrandr', '--verbose']
def test_activate_profile_auto_select_and_existing(self): self.set_xrandr_mock('test/docked.txt', 'c2989146488f57fa9dc5f7efc263b0fd1') retval = main(['--config', 'test/xprofilerc_both_example', 'activate']) assert retval == 0 assert self.xrandr.called assert self.xrandr.call_args[0][0] == [ self.xrandr_bin, '--output', 'LVDS1', '--off', '--output', 'DP2', '--mode', '1920x1080', '--pos', '0x500', '--primary', '--output', 'HDMI3', '--mode', '1920x1080', '--rotate', 'left', '--pos', '1930x0' ]
def test_activate_profile(Popen): Popen.return_value.communicate.return_value = (b'', None) Popen.return_value.wait.return_value = 0 retval = main( ['--config', 'test/xprofilerc_example', 'activate', 'docked']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == [ '/usr/bin/xrandr', '--output', 'LVDS1', '--off', '--output', 'DP2', '--mode', '1920x1080', '--pos', '0x500', '--primary', '--output', 'HDMI3', '--mode', '1920x1080', '--rotate', 'left', '--pos', '1930x0' ]
def test_activate_profile(Popen): Popen.return_value.communicate.return_value = (b'', None) Popen.return_value.wait.return_value = 0 retval = main(['--config', 'test/xprofilerc_example', 'activate', 'docked']) assert retval == 0 assert Popen.called assert Popen.call_args[0][0] == [ '/usr/bin/xrandr', '--output', 'LVDS1', '--off', '--output', 'DP2', '--mode', '1920x1080', '--pos', '0x500', '--primary', '--output', 'HDMI3', '--mode', '1920x1080', '--rotate', 'left', '--pos', '1930x0' ]
def test_list(): main(['--config', 'test/xprofilerc_example', 'list'])
def test_list_profiles_empty(self): self.set_xrandr_mock("test/docked.txt") retval = main(["--config", "test/xprofilerc_empty", "list"]) assert retval == 0 assert not self.xrandr.called
def test_activate_profile_with_dry_run(self): self.set_xrandr_mock("test/docked.txt", "c2989146488f57fa9dc5f7efc263b0fd1") retval = main(["--config", "test/xprofilerc_both_example", "activate", "--dry-run"]) assert retval == 0 assert self.xrandr.called
def test_list_profiles_empty(self): self.set_xrandr_mock('test/docked.txt') retval = main(['--config', 'test/xprofilerc_empty', 'list']) assert retval == 0 assert not self.xrandr.called
def test_activate_profile_nonexistent(): retval = main(['--config', 'test/xprofilerc_example', 'activate', 'nonexistent']) assert retval == 1
def test_activate_profile_nonexistent(): retval = main( ['--config', 'test/xprofilerc_example', 'activate', 'nonexistent']) assert retval == 1
def test_activate_profile_non_existing(self): self.set_xrandr_mock("test/docked.txt") retval = main(["--config", "test/xprofilerc_both_example", "activate", "non-existing-profile"]) assert retval == 1 assert not self.xrandr.called