Example #1
0
    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"]
Example #2
0
    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']
Example #3
0
    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']
Example #4
0
    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"]
Example #5
0
    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']
Example #6
0
    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"]
Example #7
0
    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"]
Example #8
0
    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",
        ]
Example #9
0
    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']
Example #10
0
    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
Example #11
0
    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
Example #12
0
    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
Example #13
0
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
Example #14
0
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
Example #15
0
    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
Example #16
0
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']
Example #17
0
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']
Example #18
0
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']
Example #19
0
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']
Example #20
0
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']
Example #21
0
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']
Example #22
0
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']
Example #23
0
    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'
        ]
Example #24
0
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'
    ]
Example #25
0
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'
    ]
Example #26
0
def test_list():
    main(['--config', 'test/xprofilerc_example', 'list'])
Example #27
0
def test_list():
    main(['--config', 'test/xprofilerc_example', 'list'])
Example #28
0
    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
Example #29
0
    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
Example #30
0
    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
Example #31
0
def test_activate_profile_nonexistent():
    retval = main(['--config', 'test/xprofilerc_example', 'activate', 'nonexistent'])

    assert retval == 1
Example #32
0
def test_activate_profile_nonexistent():
    retval = main(
        ['--config', 'test/xprofilerc_example', 'activate', 'nonexistent'])

    assert retval == 1
Example #33
0
    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