class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv') self.env = Environment(env_path, create=True) def tearDown(self): with self.env.db_query as db: db.close() self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_get_version(self): """Testing env.get_version""" assert self.env.get_version() == db_default.db_version def test_get_known_users(self): """Testing env.get_known_users""" with self.env.db_transaction as db: db.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)]) db.executemany( "INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(): users[username] = (name, email) assert not users.has_key('anonymous') self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane'])
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv') self.env = Environment(env_path, create=True) self.db = self.env.get_db_cnx() def tearDown(self): self.db.close() self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_get_version(self): """Testing env.get_version""" assert self.env.get_version() == db_default.db_version def test_get_known_users(self): """Testing env.get_known_users""" cursor = self.db.cursor() cursor.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0),('tom', 1), ('joe', 1), ('jane', 1)]) cursor.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username,name,email in self.env.get_known_users(self.db): users[username] = (name, email) assert not users.has_key('anonymous') self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane'])
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv') self.env = Environment(env_path, create=True, db_str='sqlite:db/trac.db') self.db = self.env.get_db_cnx() def tearDown(self): self.db.close() self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_get_version(self): """Testing env.get_version""" assert self.env.get_version() == db_default.db_version def test_get_known_users(self): """Testing env.get_known_users""" cursor = self.db.cursor() cursor.execute("INSERT INTO session " "VALUES ('123',0,'email','*****@*****.**')") cursor.executemany("INSERT INTO session VALUES (%s,1,%s,%s)", [('tom', 'name', 'Tom'), ('tom', 'email', '*****@*****.**'), ('joe', 'email', '*****@*****.**'), ('jane', 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(self.db): users[username] = (name, email) assert not users.has_key('anonymous') self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane'])
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = tempfile.mkdtemp(prefix='trac-tempenv-') self.env = Environment(env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_abs_href(self): self.assertEqual('http://trac.edgewall.org/some/path', self.env.abs_href()) def test_href(self): self.assertEqual('/some/path', self.env.href()) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) def test_get_known_users(self): """Testing env.get_known_users""" with self.env.db_transaction as db: db.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)]) db.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(): users[username] = (name, email) self.assertTrue('anonymous' not in users) self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane'])
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = os.path.join(tempfile.gettempdir(), "trac-tempenv") self.env = Environment(env_path, create=True) self.db = self.env.get_db_cnx() def tearDown(self): self.db.close() self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_get_version(self): """Testing env.get_version""" assert self.env.get_version() == db_default.db_version def test_get_known_users(self): """Testing env.get_known_users""" cursor = self.db.cursor() cursor.executemany("INSERT INTO session VALUES (%s,%s,0)", [("123", 0), ("tom", 1), ("joe", 1), ("jane", 1)]) cursor.executemany( "INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [ ("123", 0, "email", "*****@*****.**"), ("tom", 1, "name", "Tom"), ("tom", 1, "email", "*****@*****.**"), ("joe", 1, "email", "*****@*****.**"), ("jane", 1, "name", "Jane"), ], ) users = {} for username, name, email in self.env.get_known_users(self.db): users[username] = (name, email) assert not users.has_key("anonymous") self.assertEqual(("Tom", "*****@*****.**"), users["tom"]) self.assertEqual((None, "*****@*****.**"), users["joe"]) self.assertEqual(("Jane", None), users["jane"])
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = tempfile.mkdtemp(prefix='trac-tempenv-') self.env = Environment(env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_db_exc(self): db_exc = self.env.db_exc self.assertTrue(hasattr(db_exc, 'IntegrityError')) self.assertIs(db_exc, self.env.db_exc) def test_abs_href(self): abs_href = self.env.abs_href self.assertEqual('http://trac.edgewall.org/some/path', abs_href()) self.assertIs(abs_href, self.env.abs_href) def test_href(self): href = self.env.href self.assertEqual('/some/path', href()) self.assertIs(href, self.env.href) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) self.assertEqual(db_default.db_version, self.env.database_version) self.assertEqual(db_default.db_version, self.env.database_initial_version) def test_get_known_users(self): """Testing env.get_known_users""" with self.env.db_transaction as db: db.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)]) db.executemany( "INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(): users[username] = (name, email) self.assertTrue('anonymous' not in users) self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane']) def test_is_component_enabled(self): self.assertEqual(True, Environment.required) self.assertEqual(True, self.env.is_component_enabled(Environment)) self.assertEqual(False, EnvironmentStub.required) self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub)) def test_dumped_values_in_tracini(self): parser = RawConfigParser() filename = self.env.config.filename self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) def test_dumped_values_in_tracini_sample(self): parser = RawConfigParser() filename = self.env.config.filename + '.sample' self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) self.assertTrue(parser.has_option('logging', 'log_format')) self.assertEqual('', parser.get('logging', 'log_format')) def test_needs_upgrade_legacy_participant(self): """For backward compatibility with plugin, environment_needs_upgrade with a `db` argument is deprecated but still allowed.""" participants = self.env.setup_participants needs_upgrade = self.env.needs_upgrade() class LegacyParticipant(Component): implements(IEnvironmentSetupParticipant) def environment_created(self): pass def environment_needs_upgrade(self, db): return True def upgrade_environment(self, db): pass self.env.enable_component(LegacyParticipant) self.assertFalse(needs_upgrade) self.assertEqual( len(participants) + 1, len(self.env.setup_participants)) self.assertTrue(self.env.needs_upgrade()) def test_upgrade_legacy_participant(self): """For backward compatibility with plugin, upgrade with a `db` argument is deprecated but still allowed.""" participants = self.env.setup_participants class LegacyParticipant(Component): implements(IEnvironmentSetupParticipant) def environment_created(self): pass def environment_needs_upgrade(self, db): return True def upgrade_environment(self, db): pass self.env.enable_component(LegacyParticipant) self.assertEqual( len(participants) + 1, len(self.env.setup_participants)) self.assertTrue(self.env.needs_upgrade()) self.assertTrue(self.env.upgrade()) def test_invalid_log_level_raises_exception(self): self.env.config.set('logging', 'log_level', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_level')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True) def test_invalid_log_type_raises_exception(self): self.env.config.set('logging', 'log_type', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_type')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True)
class EnvironmentTestCase(unittest.TestCase): def setUp(self): self.env_path = tempfile.mkdtemp(prefix='trac-tempenv-') self.env = Environment(self.env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections rmtree(self.env.path) def test_missing_config_file_raises_trac_error(self): """TracError is raised when config file is missing.""" os.remove(self.env.config_file_path) self.assertRaises(TracError, Environment, self.env.path) def test_db_exc(self): db_exc = self.env.db_exc self.assertTrue(hasattr(db_exc, 'IntegrityError')) self.assertIs(db_exc, self.env.db_exc) def test_abs_href(self): abs_href = self.env.abs_href self.assertEqual('http://trac.edgewall.org/some/path', abs_href()) self.assertIs(abs_href, self.env.abs_href) def test_href(self): href = self.env.href self.assertEqual('/some/path', href()) self.assertIs(href, self.env.href) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) self.assertEqual(db_default.db_version, self.env.database_version) self.assertEqual(db_default.db_version, self.env.database_initial_version) def test_is_component_enabled(self): self.assertEqual(True, Environment.required) self.assertEqual(True, self.env.is_component_enabled(Environment)) self.assertEqual(False, EnvironmentStub.required) self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub)) def test_log_format(self): """Configure the log_format and log to a file at WARNING level.""" self.env.config.set('logging', 'log_type', 'file') self.env.config.set('logging', 'log_level', 'WARNING') self.env.config.set('logging', 'log_format', 'Trac[$(module)s] $(project)s: $(message)s') self.env.config.save() self.env.shutdown() self.env = Environment(self.env_path) # Reload environment self.env.log.warning("The warning message") with open(os.path.join(self.env.log_dir, self.env.log_file)) as f: log = f.readlines() self.assertEqual("Trac[env] My Project: The warning message\n", log[-1]) def test_dumped_values_in_tracini(self): parser = RawConfigParser() filename = self.env.config.filename self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) def test_dumped_values_in_tracini_sample(self): parser = RawConfigParser() filename = self.env.config.filename + '.sample' self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) self.assertTrue(parser.has_option('logging', 'log_format')) self.assertEqual('', parser.get('logging', 'log_format')) def test_invalid_log_level_raises_exception(self): self.env.config.set('logging', 'log_level', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_level')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True) def test_invalid_log_type_raises_exception(self): self.env.config.set('logging', 'log_type', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_type')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True) def test_log_level_not_case_sensitive(self): """[logging] log_level is not case-sensitive.""" self.env.config.set('logging', 'log_level', 'warning') self.env.config.save() self.assertEqual('warning', self.env.config.get('logging', 'log_level')) self.assertEqual('WARNING', self.env.log_level) def test_log_type_not_case_sensitive(self): """[logging] log_type is not case-sensitive.""" self.env.config.set('logging', 'log_type', 'File') self.env.config.save() self.assertEqual('File', self.env.config.get('logging', 'log_type')) self.assertEqual('file', self.env.log_type)
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = tempfile.mkdtemp(prefix='trac-tempenv-') self.env = Environment(env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_db_exc(self): db_exc = self.env.db_exc self.assertTrue(hasattr(db_exc, 'IntegrityError')) self.assertIs(db_exc, self.env.db_exc) def test_abs_href(self): abs_href = self.env.abs_href self.assertEqual('http://trac.edgewall.org/some/path', abs_href()) self.assertIs(abs_href, self.env.abs_href) def test_href(self): href = self.env.href self.assertEqual('/some/path', href()) self.assertIs(href, self.env.href) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) self.assertEqual(db_default.db_version, self.env.database_version) self.assertEqual(db_default.db_version, self.env.database_initial_version) def test_get_known_users(self): """Testing env.get_known_users""" with self.env.db_transaction as db: db.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)]) db.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(): users[username] = (name, email) self.assertTrue('anonymous' not in users) self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane']) def test_is_component_enabled(self): self.assertEqual(True, Environment.required) self.assertEqual(True, self.env.is_component_enabled(Environment)) self.assertEqual(False, EnvironmentStub.required) self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub)) def test_dumped_values_in_tracini(self): parser = RawConfigParser() filename = self.env.config.filename self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) def test_dumped_values_in_tracini_sample(self): parser = RawConfigParser() filename = self.env.config.filename + '.sample' self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) self.assertTrue(parser.has_option('logging', 'log_format')) self.assertEqual('', parser.get('logging', 'log_format'))
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = tempfile.mkdtemp(prefix='trac-tempenv-') # self.addCleanup(self.cleanupEnvPath, env_path) self.env = Environment(env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_missing_config_file_raises_trac_error(self): """TracError is raised when config file is missing.""" os.remove(os.path.join(self.env.path, 'conf', 'trac.ini')) self.assertRaises(TracError, Environment, self.env.path) def test_db_exc(self): db_exc = self.env.db_exc self.assertTrue(hasattr(db_exc, 'IntegrityError')) self.assertIs(db_exc, self.env.db_exc) def test_abs_href(self): abs_href = self.env.abs_href self.assertEqual('http://trac.edgewall.org/some/path', abs_href()) self.assertIs(abs_href, self.env.abs_href) def test_href(self): href = self.env.href self.assertEqual('/some/path', href()) self.assertIs(href, self.env.href) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) self.assertEqual(db_default.db_version, self.env.database_version) self.assertEqual(db_default.db_version, self.env.database_initial_version) def test_get_known_users(self): """Testing env.get_known_users""" with self.env.db_transaction as db: db.executemany("INSERT INTO session VALUES (%s,%s,0)", [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)]) db.executemany( "INSERT INTO session_attribute VALUES (%s,%s,%s,%s)", [('123', 0, 'email', '*****@*****.**'), ('tom', 1, 'name', 'Tom'), ('tom', 1, 'email', '*****@*****.**'), ('joe', 1, 'email', '*****@*****.**'), ('jane', 1, 'name', 'Jane')]) users = {} for username, name, email in self.env.get_known_users(): users[username] = (name, email) self.assertTrue('anonymous' not in users) self.assertEqual(('Tom', '*****@*****.**'), users['tom']) self.assertEqual((None, '*****@*****.**'), users['joe']) self.assertEqual(('Jane', None), users['jane']) def test_is_component_enabled(self): self.assertEqual(True, Environment.required) self.assertEqual(True, self.env.is_component_enabled(Environment)) self.assertEqual(False, EnvironmentStub.required) self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub)) def test_dumped_values_in_tracini(self): parser = RawConfigParser() filename = self.env.config.filename self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) def test_dumped_values_in_tracini_sample(self): parser = RawConfigParser() filename = self.env.config.filename + '.sample' self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) self.assertTrue(parser.has_option('logging', 'log_format')) self.assertEqual('', parser.get('logging', 'log_format'))
class EnvironmentTestCase(unittest.TestCase): def setUp(self): env_path = tempfile.mkdtemp(prefix='trac-tempenv-') self.env = Environment(env_path, create=True) self.env.config.set('trac', 'base_url', 'http://trac.edgewall.org/some/path') self.env.config.save() def tearDown(self): self.env.shutdown() # really closes the db connections shutil.rmtree(self.env.path) def test_db_exc(self): db_exc = self.env.db_exc self.assertTrue(hasattr(db_exc, 'IntegrityError')) self.assertIs(db_exc, self.env.db_exc) def test_abs_href(self): abs_href = self.env.abs_href self.assertEqual('http://trac.edgewall.org/some/path', abs_href()) self.assertIs(abs_href, self.env.abs_href) def test_href(self): href = self.env.href self.assertEqual('/some/path', href()) self.assertIs(href, self.env.href) def test_get_version(self): """Testing env.get_version""" self.assertEqual(db_default.db_version, self.env.get_version()) self.assertEqual(db_default.db_version, self.env.database_version) self.assertEqual(db_default.db_version, self.env.database_initial_version) def test_is_component_enabled(self): self.assertEqual(True, Environment.required) self.assertEqual(True, self.env.is_component_enabled(Environment)) self.assertEqual(False, EnvironmentStub.required) self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub)) def test_dumped_values_in_tracini(self): parser = RawConfigParser() filename = self.env.config.filename self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) def test_dumped_values_in_tracini_sample(self): parser = RawConfigParser() filename = self.env.config.filename + '.sample' self.assertEqual([filename], parser.read(filename)) self.assertEqual('#cc0,#0c0,#0cc,#00c,#c0c,#c00', parser.get('revisionlog', 'graph_colors')) self.assertEqual('disabled', parser.get('trac', 'secure_cookies')) self.assertTrue(parser.has_option('logging', 'log_format')) self.assertEqual('', parser.get('logging', 'log_format')) def test_needs_upgrade_legacy_participant(self): """For backward compatibility with plugin, environment_needs_upgrade with a `db` argument is deprecated but still allowed.""" participants = self.env.setup_participants needs_upgrade = self.env.needs_upgrade() class LegacyParticipant(Component): implements(IEnvironmentSetupParticipant) def environment_created(self): pass def environment_needs_upgrade(self, db): return True def upgrade_environment(self, db): pass self.env.enable_component(LegacyParticipant) self.assertFalse(needs_upgrade) self.assertEqual(len(participants) + 1, len(self.env.setup_participants)) self.assertTrue(self.env.needs_upgrade()) def test_upgrade_legacy_participant(self): """For backward compatibility with plugin, upgrade with a `db` argument is deprecated but still allowed.""" participants = self.env.setup_participants class LegacyParticipant(Component): implements(IEnvironmentSetupParticipant) def environment_created(self): pass def environment_needs_upgrade(self, db): return True def upgrade_environment(self, db): pass self.env.enable_component(LegacyParticipant) self.assertEqual(len(participants) + 1, len(self.env.setup_participants)) self.assertTrue(self.env.needs_upgrade()) self.assertTrue(self.env.upgrade()) def test_invalid_log_level_raises_exception(self): self.env.config.set('logging', 'log_level', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_level')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True) def test_invalid_log_type_raises_exception(self): self.env.config.set('logging', 'log_type', 'invalid') self.env.config.save() self.assertEqual('invalid', self.env.config.get('logging', 'log_type')) self.assertRaises(ConfigurationError, open_environment, self.env.path, True)