예제 #1
0
 def test_invalid_config(self):
     with self.assertRaisesRegexp(
             Exception, 'Invalid line in invalid_feconf_updates.config '
             'config file: INVALID_KEY: \'invalid\''):
         update_configs.apply_changes_based_on_config(
             MOCK_LOCAL_FECONF_PATH, INVALID_FECONF_CONFIG_PATH,
             update_configs.FECONF_REGEX)
예제 #2
0
 def test_missing_line_in_local_config(self):
     with self.assertRaisesRegexp(
             Exception, 'Could not find correct number of lines in '
             'feconf.txt matching: EXTRA_KEY = \'extra\''):
         update_configs.apply_changes_based_on_config(
             MOCK_LOCAL_FECONF_PATH, FECONF_CONFIG_PATH_WITH_EXTRA_LINE,
             update_configs.FECONF_REGEX)
예제 #3
0
 def test_invalid_config(self):
     config_swap = self.swap(update_configs, 'FECONF_CONFIG_PATH',
                             INVALID_FECONF_CONFIG_PATH)
     with self.feconf_swap, config_swap, self.assertRaisesRegexp(
             Exception, 'Invalid line in invalid_feconf_updates.config '
             'config file: INVALID_KEY: \'invalid\''):
         update_configs.apply_changes_based_on_config(
             update_configs.LOCAL_FECONF_PATH,
             update_configs.FECONF_CONFIG_PATH, update_configs.FECONF_REGEX)
예제 #4
0
 def test_changes_are_applied_to_config(self):
     with python_utils.open_file(MOCK_LOCAL_FECONF_PATH, 'r') as f:
         original_text = f.read()
     expected_text = original_text.replace(
         'INCOMING_EMAILS_DOMAIN_NAME = \'\'',
         'INCOMING_EMAILS_DOMAIN_NAME = \'oppia.org\'')
     try:
         update_configs.apply_changes_based_on_config(
             MOCK_LOCAL_FECONF_PATH, VALID_FECONF_CONFIG_PATH,
             update_configs.FECONF_REGEX)
         with python_utils.open_file(MOCK_LOCAL_FECONF_PATH, 'r') as f:
             self.assertEqual(f.read(), expected_text)
     finally:
         with python_utils.open_file(MOCK_LOCAL_FECONF_PATH, 'w') as f:
             f.write(original_text)