Task #989
Updated by bmbouter over 9 years ago
Currently if you make a call to "get_database()":https://github.com/pulp/pulp/blob/d17e9e5c3fe2a3a2b81ef252304984c40003b7b7/server/pulp/server/db/connection.py#L255 or "get_connection()":https://github.com/pulp/pulp/blob/d17e9e5c3fe2a3a2b81ef252304984c40003b7b7/server/pulp/server/db/connection.py#L263 without calling "initialize()":https://github.com/pulp/pulp/blob/d17e9e5c3fe2a3a2b81ef252304984c40003b7b7/server/pulp/server/db/connection.py#L31 first, you would have None returned to you. Code that uses those will then fail in unexpected ways. This story is to add a behavior to get_database() and get_connection() such that if _DATABASE or _CONNECTION are None that an Exception is raised. This is similar to what is already implemented in "get_collection":https://github.com/pulp/pulp/blob/d17e9e5c3fe2a3a2b81ef252304984c40003b7b7/server/pulp/server/db/connection.py#L249. Also, PulpCollectionFailure should be renamed to PulpDatabaseFailure so that it carries a name appropriate to be raised from all 3 of these functions. Each function that raises should use an error message appropriate for the function that was called. These two steps were originally steps (3) and (5) from story #131. h2. Deliverables 1. Add behavior to get_database() 2. Add behavior to get_connection() 3. Rename PulpCollectionFailure to PulpDatabaseFailure 4. Add tests to assert the raise behaviors for get_collection(), get_database(), and get_connection()