Beispiel #1
0
 def test_context_enter(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert len(app.context_path) == 0
     ctx1 = 'first_context'
     app.context_enter(ctx1)
     assert len(app.context_path) == 1
     assert app.context_path[0] == ctx1
Beispiel #2
0
 def test_context_enter_next_id(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert len(app.context_path) == 0
     assert app.context_id == ""
     ctx1 = 'first_context'
     ctx2 = '2nd_context'
     app.context_enter(ctx1, ctx2)
     assert len(app.context_path) == 1
     assert app.context_path[0] == ctx1
     assert app.context_id == ctx2
Beispiel #3
0
    def test_load_app_states(self, ini_file, restore_app_env):
        app = KivyMainApp(additional_cfg_files=(ini_file, ))
        assert app.get_var(TST_VAR, section=APP_STATE_SECTION_NAME) == TST_VAL

        app.load_app_states()
        assert getattr(app, TST_VAR) == TST_VAL
        assert app.framework_app.app_state == TST_DICT
        assert app.retrieve_app_states() == TST_DICT
Beispiel #4
0
    def test_context_leave_next_id(self, ini_file, restore_app_env):
        app = KivyMainApp(additional_cfg_files=(ini_file, ))
        ctx1 = 'first_context'
        ctx2 = '2nd_context'
        ctx3 = '3rd_context'
        app.context_enter(ctx1, ctx2)

        app.context_leave(next_context_id=ctx3)

        assert len(app.context_path) == 0
        assert app.context_id == ctx3
Beispiel #5
0
    def test_save_app_states(self, ini_file, restore_app_env):
        global TST_DICT
        app = KivyMainApp(additional_cfg_files=(ini_file, ))
        old_dict = TST_DICT.copy()
        try:
            assert app.get_var(TST_VAR,
                               section=APP_STATE_SECTION_NAME) == TST_VAL
            assert app.retrieve_app_states() == TST_DICT

            chg_val = 'ChangedVal'
            TST_DICT = {TST_VAR: chg_val}
            setattr(app, TST_VAR, chg_val)
            assert app.save_app_states() == ""
            assert app.get_var(TST_VAR,
                               section=APP_STATE_SECTION_NAME) == chg_val
            assert app.retrieve_app_states() == TST_DICT
        finally:
            TST_DICT = old_dict
Beispiel #6
0
 def test_retrieve_app_states(self, restore_app_env):
     app = KivyMainApp()
     assert app.retrieve_app_states() == dict()
Beispiel #7
0
 def test_setup_app_states(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert getattr(app, TST_VAR) == def_app_state[TST_VAR]
Beispiel #8
0
 def test_play_beep(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert app.play_beep() is None
Beispiel #9
0
 def test_call_event_invalid_method(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert app.call_event('invalid_method_name') is None
Beispiel #10
0
 def test_save_app_states_exception(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     os.remove(ini_file)
     assert app.save_app_states() != ""
Beispiel #11
0
    def test_change_app_state(self, ini_file, restore_app_env):
        app = KivyMainApp(additional_cfg_files=(ini_file, ))
        assert app.save_app_states() == ""
        assert app.get_var(TST_VAR, section=APP_STATE_SECTION_NAME) == TST_VAL
        assert app.retrieve_app_states() == TST_DICT

        chg_val = 'ChangedVal'
        chg_dict = {TST_VAR: chg_val}
        app.change_app_state(TST_VAR, chg_val)

        assert getattr(app, TST_VAR) == chg_val
        assert app.framework_app.app_state == chg_dict
        assert app.retrieve_app_states() == chg_dict

        assert app.get_var(TST_VAR, section=APP_STATE_SECTION_NAME) == TST_VAL
        assert app.save_app_states() == ""
        assert app.get_var(TST_VAR, section=APP_STATE_SECTION_NAME) == chg_val
Beispiel #12
0
 def test_setup_app_states(self, ini_file, restore_app_env):
     assert KivyMainApp.win_rectangle == def_app_state['win_rectangle']
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert getattr(app, TST_VAR) == TST_VAL
     app.setup_app_states(TST_DICT)
     assert getattr(app, TST_VAR) == TST_VAL
Beispiel #13
0
 def test_retrieve_app_states(self, ini_file, restore_app_env):
     app = KivyMainApp(additional_cfg_files=(ini_file, ))
     assert app.get_var(TST_VAR, section=APP_STATE_SECTION_NAME) == TST_VAL
     assert app.retrieve_app_states() == TST_DICT