예제 #1
0
class TestProcessREB1:
    # @classmethod
    # def setup_class(cls):

    def setup_method(self, method):
        self.app = MacroZero(test_env=True, run_webserver=False)

    def test_process_re_b1_re_mode_buttons(self):
        """
        Tests that _process_re_b1 flips rotary_encode_mode and returns OK
        rotary_encoder_mode = buttons -> modes
        :return:
        """
        self.app.rotary_encoder_mode = ROTARY_ENCODER_BUTTONS
        result = self.app._process_re_b1()
        assert self.app.rotary_encoder_mode == ROTARY_ENCODER_MODES
        assert result == STATUS_OK

    def test_process_re_b1_re_mode_modes(self):
        """
        Tests that _process_re_b1 flips rotary_encode_mode and returns OK
        rotary_encoder_mode = modes -> buttons
        :return:
        """
        self.app.rotary_encoder_mode = ROTARY_ENCODER_MODES
        result = self.app._process_re_b1()
        assert self.app.rotary_encoder_mode == ROTARY_ENCODER_BUTTONS
        assert result == STATUS_OK

    def teardown_method(self, method):
        del self.app
예제 #2
0
class TestInvalidCommand:
    # @classmethod
    # def setup_class(cls):

    def setup_method(self, method):
        self.app = MacroZero(test_env=True, run_webserver=False)

    def test_invalid_command(self):
        """
        Tests that invalid_command returns ValueError
        :return:
        """
        with pytest.raises(ValueError):
            self.app._invalid_command()

    def teardown_method(self, method):
        del self.app
class TestLoadConfiguration:
    # @classmethod
    # def setup_class(cls):

    def setup_method(self, method):
        self.app = MacroZero(test_env=True, run_webserver=False)

    def test_load_configuration_returns_dictionary(self):
        """
        Tests that load_configuration loads data from json file into dictionary
        :return:
        """
        self.app.load_configuration()
        assert isinstance(self.app.configuration, dict)

    def teardown_method(self, method):
        del self.app
예제 #4
0
class TestInit:
    # @classmethod
    # def setup_class(cls):

    def setup_method(self, method):
        self.app = MacroZero(test_env=True, run_webserver=False)

    @pytest.mark.skipif(RUNNING_ON_PI is False,
                        reason="Requires running on Raspberry-Pi")
    def test_init(self):
        """
        Tests that macro-zero runs init correctly
        :return:
        """
        result = self.app.init()
        assert result is True

    def teardown_method(self, method):
        del self.app
예제 #5
0
 def setup_method(self, method):
     self.app = MacroZero(test_env=True, run_webserver=False)
예제 #6
0
def app():
    app = MacroZero(test_env=True, run_webserver=False)

    yield app