Beispiel #1
0
    def test_enable_rule_causes_a_save(self):
        from castervoice.lib import utilities
        from castervoice.lib.ctrl.rules_config import RulesConfig
        from castervoice.rules.core.alphabet_rules import alphabet
        from castervoice.rules.core.punctuation_rules import punctuation

        # "write" the rules.toml file:
        self._setup_rules_config_file(
            loadable_true=["Alphabet", "Punctuation"], enabled=["Alphabet"])

        # check that the mock file changes were written
        self.assertEqual(
            1, len(self._rule_config._config[RulesConfig._ENABLED_ORDERED]))

        # initialize the gm
        a, b = alphabet.get_rule(), punctuation.get_rule()
        self._initialize(FullContentSet([a, b], [], []))

        # simulate a spoken "enable" command from the GrammarActivator:
        self._gm._change_rule_enabled("Punctuation", True)
        # afterwards, the config should have both Alphabet and Punctuation enabled
        config = utilities.load_toml_file(
            TestGrammarManager._MOCK_PATH_RULES_CONFIG)
        self.assertIn("Alphabet", config[RulesConfig._ENABLED_ORDERED])
        self.assertIn("Punctuation", config[RulesConfig._ENABLED_ORDERED])
Beispiel #2
0
 def test_initialize_two_compatible_global_mergerules(self):
     from castervoice.rules.core.alphabet_rules import alphabet
     from castervoice.rules.core.punctuation_rules import punctuation
     self._setup_rules_config_file(
         loadable_true=["Alphabet", "Punctuation"],
         enabled=["Alphabet", "Punctuation"])
     a = alphabet.get_rule()
     b = punctuation.get_rule()
     self._initialize(FullContentSet([a, b], [], []))
     self.assertEqual(2, len(self._gm._grammars_container.non_ccr.keys()))
     self.assertEqual(1, len(self._gm._grammars_container.ccr))