Package trac :: Module test :: Class EnvironmentStub

Class EnvironmentStub

source code

           object --+        
                    |        
       core.Component --+    
                        |    
           object --+   |    
                    |   |    
core.ComponentManager --+    
                        |    
          env.Environment --+
                            |
                           EnvironmentStub

A stub of the trac.env.Environment class for testing.
Nested Classes

Inherited from core.Component: __metaclass__

Instance Methods
 
__init__(self, default_data=False, enable=None, disable=None, path=None, destroying=False)
Construct a new Environment stub object.
source code
 
reset_db(self, default_data=None)
Remove all data from Trac tables, keeping the tables themselves.
source code
 
destroy_db(self, scheme=None, db_prop=None)
Destroy the database.
source code
 
clear_component_registry(self)
Clear the component registry.
source code
 
restore_component_registry(self)
Restore the component registry.
source code
 
reset_db_and_disk(self)
Performs a complete environment reset in a robust way.
source code
 
insert_users(self, users)
Insert a tuple representing a user session to the session and session_attributes tables.
source code
 
is_component_enabled(self, cls)
Implemented to only allow activation of components that are not disabled in the configuration.
source code

Inherited from env.Environment: __repr__, backup, component_activated, components_section, create, create_logger, enable_component, get_htdocs_dir, get_known_users, get_log_dir, get_read_db, get_repository, get_system_info, get_systeminfo, get_templates_dir, get_version, invalidate_known_users_cache, needs_upgrade, setup_config, setup_log, shutdown, upgrade, verify, with_transaction

Inherited from core.ComponentManager: __contains__, __getitem__, disable_component, is_enabled

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods

Inherited from core.Component: implements

Class Variables
  global_databasemanager = None
hash(x)
  required = False
  abstract = True

Inherited from env.Environment: abs_href, anonymous_session_lifetime, base_url, base_url_for_redirect, conf_dir, config_file_path, database_initial_version, database_version, db_exc, href, htdocs_dir, log_dir, log_file, log_format, log_level, log_type, name, plugins_dir, project_admin, project_admin_trac_url, project_description, project_footer, project_icon, project_name, project_url, secure_cookies, shared_plugins_dir, templates_dir, trac_version

Properties

Inherited from env.Environment: db_query, db_transaction, env, setup_participants, system_info_providers

Inherited from object: __class__

Method Details

__init__(self, default_data=False, enable=None, disable=None, path=None, destroying=False)
(Constructor)

source code 
Construct a new Environment stub object.
Parameters:
  • default_data - If True, populate the database with some defaults.
  • enable - A list of component classes or name globs to activate in the stub environment.
  • disable - A list of component classes or name globs to deactivate in the stub environment.
  • path - The location of the environment in the file system. No files or directories are created when specifying this parameter.
  • destroying - If True, the database will not be reset. This is useful for cases when the object is being constructed in order to call destroy_db.
Overrides: object.__init__

reset_db(self, default_data=None)

source code 
Remove all data from Trac tables, keeping the tables themselves.
Parameters:
  • default_data - after clean-up, initialize with default data
Returns:
True upon success

clear_component_registry(self)

source code 

Clear the component registry.

The registry entries are saved entries so they can be restored later using the restore_component_registry method.

Since: 1.0.11

restore_component_registry(self)

source code 

Restore the component registry.

The component registry must have been cleared and saved using the clear_component_registry method.

Since: 1.0.11

reset_db_and_disk(self)

source code 

Performs a complete environment reset in a robust way.

The database is reset, then the connections are shut down, and finally all environment files are removed from the disk.

insert_users(self, users)

source code 

Insert a tuple representing a user session to the session and session_attributes tables.

The tuple can be length 3 with entries username, name and email, in which case an authenticated user is assumed. The tuple can also be length 4, with the last entry specifying 1 for an authenticated user or 0 for an unauthenticated user.

is_component_enabled(self, cls)

source code 

Implemented to only allow activation of components that are not disabled in the configuration.

This is called by the ComponentManager base class when a component is about to be activated. If this method returns False, the component does not get activated. If it returns None, the component only gets activated if it is located in the plugins directory of the environment.

Overrides: core.ComponentManager.is_component_enabled
(inherited documentation)