From a47860e73c68ffbba97f1a70355223a2052a5f3c Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Sun, 5 Mar 2017 14:02:11 +0100 Subject: [PATCH] [tests] Add unit tests for pulseaudio module --- tests/modules/test_pulseaudio.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/modules/test_pulseaudio.py diff --git a/tests/modules/test_pulseaudio.py b/tests/modules/test_pulseaudio.py new file mode 100644 index 0000000..f8754c6 --- /dev/null +++ b/tests/modules/test_pulseaudio.py @@ -0,0 +1,34 @@ +# pylint: disable=C0103,C0111 + +import mock +import unittest + +import tests.mocks as mocks + +from bumblebee.input import LEFT_MOUSE, RIGHT_MOUSE, WHEEL_UP, WHEEL_DOWN +from bumblebee.modules.pulseaudio import Module + +class TestPulseAudioModule(unittest.TestCase): + def setUp(self): + mocks.setup_test(self, Module) + + def tearDown(self): + mocks.teardown_test(self) + + def test_leftclick(self): + mocks.mouseEvent(stdin=self.stdin, button=LEFT_MOUSE, inp=self.input, module=self.module) + self.popen.assert_call("pactl set-source-mute @DEFAULT_SOURCE@ toggle") + + def test_rightclick(self): + mocks.mouseEvent(stdin=self.stdin, button=RIGHT_MOUSE, inp=self.input, module=self.module) + self.popen.assert_call("pavucontrol") + + def test_wheelup(self): + mocks.mouseEvent(stdin=self.stdin, button=WHEEL_UP, inp=self.input, module=self.module) + self.popen.assert_call("pactl set-source-volume @DEFAULT_SOURCE@ +2%") + + def test_wheeldown(self): + mocks.mouseEvent(stdin=self.stdin, button=WHEEL_DOWN, inp=self.input, module=self.module) + self.popen.assert_call("pactl set-source-volume @DEFAULT_SOURCE@ -2%") + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4