예제 #1
0
 def test_create_test_db(self, *mocked_objects):
     creation = DatabaseCreation(connection)
     # Simulate test database creation raising "database already exists"
     with self.patch_test_db_creation(
             self._execute_raise_database_already_exists):
         with mock.patch('builtins.input', return_value='no'):
             with self.assertRaises(SystemExit):
                 # SystemExit is raised if the user answers "no" to the
                 # prompt asking if it's okay to delete the test database.
                 creation._create_test_db(verbosity=0,
                                          autoclobber=False,
                                          keepdb=False)
         # "Database already exists" error is ignored when keepdb is on
         creation._create_test_db(verbosity=0,
                                  autoclobber=False,
                                  keepdb=True)
     # Simulate test database creation raising unexpected error
     with self.patch_test_db_creation(
             self._execute_raise_permission_denied):
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0,
                                      autoclobber=False,
                                      keepdb=False)
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0,
                                      autoclobber=False,
                                      keepdb=True)
예제 #2
0
    def __init__(self, *args, **kwargs):
        super(DatabaseWrapper, self).__init__(*args, **kwargs)

        self.features = DatabaseFeatures()
        self.ops = DatabaseOperations(self)
        self.client = DatabaseClient(self)
        self.creation = DatabaseCreation(self)
        self.introspection = DatabaseIntrospection(self)
        self.validation = BaseDatabaseValidation(self)
예제 #3
0
 def test_create_test_db(self, *mocked_objects):
     creation = DatabaseCreation(connection)
     # Simulate test database creation raising "database already exists"
     with self.patch_test_db_creation(self._execute_raise_database_already_exists):
         with mock.patch('builtins.input', return_value='no'):
             with self.assertRaises(SystemExit):
                 # SystemExit is raised if the user answers "no" to the
                 # prompt asking if it's okay to delete the test database.
                 creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False)
         # "Database already exists" error is ignored when keepdb is on
         creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True)
     # Simulate test database creation raising unexpected error
     with self.patch_test_db_creation(self._execute_raise_permission_denied):
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False)
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True)
예제 #4
0
    def __init__(self, *args, **kwargs):
        super(DatabaseWrapper, self).__init__(*args, **kwargs)

        self.features = DatabaseFeatures()
        autocommit = self.settings_dict["OPTIONS"].get('autocommit', False)
        self.features.uses_autocommit = autocommit
        self._set_isolation_level(int(not autocommit))
        self.ops = DatabaseOperations(self)
        self.client = DatabaseClient(self)
        self.creation = DatabaseCreation(self)
        self.introspection = DatabaseIntrospection(self)
        self.validation = BaseDatabaseValidation(self)
예제 #5
0
파일: base.py 프로젝트: raj88iitr/applause
    def __init__(self, *args, **kwargs):
        super(DatabaseWrapper, self).__init__(*args, **kwargs)

        import warnings
        warnings.warn(
            'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.',
            DeprecationWarning)

        self.features = DatabaseFeatures(self)
        self.ops = DatabaseOperations(self)
        self.client = DatabaseClient(self)
        self.creation = DatabaseCreation(self)
        self.introspection = DatabaseIntrospection(self)
        self.validation = BaseDatabaseValidation(self)
예제 #6
0
 def check_sql_table_creation_suffix(self, settings, expected):
     with self.changed_test_settings(**settings):
         creation = PostgreSQLDatabaseCreation(connection)
         suffix = creation.sql_table_creation_suffix()
         self.assertEqual(suffix, expected)
예제 #7
0
 def check_sql_table_creation_suffix(self, settings, expected):
     with self.changed_test_settings(**settings):
         creation = DatabaseCreation(connection)
         suffix = creation.sql_table_creation_suffix()
         self.assertEqual(suffix, expected)
예제 #8
0
 def test_create_test_db(self, *mocked_objects):
     creation = DatabaseCreation(connection)
     # Simulate test database creation raising "database already exists"
     with self.patch_test_db_creation(
             self._execute_raise_database_already_exists):
         with mock.patch("builtins.input", return_value="no"):
             with self.assertRaises(SystemExit):
                 # SystemExit is raised if the user answers "no" to the
                 # prompt asking if it's okay to delete the test database.
                 creation._create_test_db(verbosity=0,
                                          autoclobber=False,
                                          keepdb=False)
         # "Database already exists" error is ignored when keepdb is on
         creation._create_test_db(verbosity=0,
                                  autoclobber=False,
                                  keepdb=True)
     # Simulate test database creation raising unexpected error
     with self.patch_test_db_creation(
             self._execute_raise_permission_denied):
         with mock.patch.object(DatabaseCreation,
                                "_database_exists",
                                return_value=False):
             with self.assertRaises(SystemExit):
                 creation._create_test_db(verbosity=0,
                                          autoclobber=False,
                                          keepdb=False)
             with self.assertRaises(SystemExit):
                 creation._create_test_db(verbosity=0,
                                          autoclobber=False,
                                          keepdb=True)
     # Simulate test database creation raising "insufficient privileges".
     # An error shouldn't appear when keepdb is on and the database already
     # exists.
     with self.patch_test_db_creation(
             self._execute_raise_permission_denied):
         with mock.patch.object(DatabaseCreation,
                                "_database_exists",
                                return_value=True):
             creation._create_test_db(verbosity=0,
                                      autoclobber=False,
                                      keepdb=True)