Exemple #1
0
        def test_main_configs_in_jobs_file(self, print_):
            try:
                _backupO = backups.Backups()
                _backupFilename = _backupO.backup_file(
                    TEST_PLAYER_JSON, _keep_the_original=True)

                # check before changes
                _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
                _player = _JSNO_O.read(TEST_PLAYER_JSON)
                assert _player["Graphic Options"]["Track Detail"] == 0, \
                    _player["Graphic Options"]["Track Detail"]
                assert _player["Graphic Options"]["Texture Filter"] == 0, \
                    _player["Graphic Options"]["Texture Filter"]

                sys.argv = [
                    'ScriptedJsonEditor',
                    r'Tests\jobs_test_configs.json']

                _exit_code, _status = ScriptedJsonEditor.main()

                # check the changes were made
                _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
                _player = _JSNO_O.read(TEST_PLAYER_JSON)
                assert _player["Graphic Options"]["Track Detail"] == 1, \
                    _player["Graphic Options"]["Track Detail"]
                assert _player["Graphic Options"]["Texture Filter"] == 4, \
                    _player["Graphic Options"][""]

            finally:
                # restore the original player.JSON
                _backupO.restore_last_backup(TEST_PLAYER_JSON)
    def test_whole_example_job(self):
        sys.argv = ['ScriptedJsonEditor', 'jobs\\VR_G25.json']
        try:
            _backupO = backups.Backups()
            _backupFilename = _backupO.backup_file(PLAYER_JSON,
                                                   _keep_the_original=True)
            _backupFilename = _backupO.backup_file(CONTROLLER_JSON,
                                                   _keep_the_original=True)

            _exit_code, _status = ScriptedJsonEditor.main()

            # check the changes were made
            _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
            _player = _JSNO_O.read(PLAYER_JSON)
            #assert _player["Graphic Options"]["Allow Letterboxing"] == False, _player["Graphic Options"]["Allow Letterboxing"]
            #assert _player["Graphic Options"]["Automap"] == 3, _player["Graphic Options"]["Automap"]

        finally:
            # restore the original player.JSON
            _backupO.restore_last_backup(PLAYER_JSON)
            _backupO.restore_last_backup(CONTROLLER_JSON)

        assert _exit_code == 0
Exemple #3
0
    def test_main(self, print_):                        # Note added , print_ to mock print()
        try:
            _backupO = backups.Backups()
            _backupFilename = _backupO.backup_file(
                TEST_PLAYER_JSON, _keep_the_original=True)

            # check before changes
            _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
            _player = _JSNO_O.read(TEST_PLAYER_JSON)
            assert _player["Graphic Options"]["Allow Letterboxing"], \
                _player["Graphic Options"]["Allow Letterboxing"]
            assert _player["Graphic Options"]["Automap"] == 3, \
                _player["Graphic Options"]["Automap"]

            sys.argv = ['ScriptedJsonEditor', r'Tests\jobs_test1.json']

            _exit_code, _status = ScriptedJsonEditor.main()

            # check the changes were made
            _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
            _player = _JSNO_O.read(TEST_PLAYER_JSON)
            assert _player["Graphic Options"]["Allow Letterboxing"] == False, \
                _player["Graphic Options"]["Allow Letterboxing"]
            assert _player["Graphic Options"]["Automap"] == 2, \
                _player["Graphic Options"]["Automap"]

        finally:
            # restore the original player.JSON
            _backupO.restore_last_backup(TEST_PLAYER_JSON)

        assert _exit_code == 0

        # Mock the print call in main()
        @patch('ScriptedJsonEditor.print', create=True)
        # Note added , print_ to mock print()
        def test_main_configs_in_jobs_file(self, print_):
            try:
                _backupO = backups.Backups()
                _backupFilename = _backupO.backup_file(
                    TEST_PLAYER_JSON, _keep_the_original=True)

                # check before changes
                _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
                _player = _JSNO_O.read(TEST_PLAYER_JSON)
                assert _player["Graphic Options"]["Track Detail"] == 0, \
                    _player["Graphic Options"]["Track Detail"]
                assert _player["Graphic Options"]["Texture Filter"] == 0, \
                    _player["Graphic Options"]["Texture Filter"]

                sys.argv = [
                    'ScriptedJsonEditor',
                    r'Tests\jobs_test_configs.json']

                _exit_code, _status = ScriptedJsonEditor.main()

                # check the changes were made
                _JSNO_O = ScriptedJsonEditor.JsonRfactorFile()
                _player = _JSNO_O.read(TEST_PLAYER_JSON)
                assert _player["Graphic Options"]["Track Detail"] == 1, \
                    _player["Graphic Options"]["Track Detail"]
                assert _player["Graphic Options"]["Texture Filter"] == 4, \
                    _player["Graphic Options"][""]

            finally:
                # restore the original player.JSON
                _backupO.restore_last_backup(TEST_PLAYER_JSON)

        assert _exit_code == 0
Exemple #4
0
 def test_main_non_existent_jobs_file(self, print_):
     sys.argv = ['ScriptedJsonEditor', 'JsonEditorJobs.json']
     assert ScriptedJsonEditor.main()[0] != 0