Exemplo n.º 1
0
    def test_oracle_managed_files(self, *mocked_objects):
        def _execute_capture_statements(self,
                                        cursor,
                                        statements,
                                        parameters,
                                        verbosity,
                                        allow_quiet_fail=False):
            self.tblspace_sqls = statements

        creation = DatabaseCreation(connection)
        # Simulate test database creation with Oracle Managed File (OMF)
        # tablespaces.
        with mock.patch.object(DatabaseCreation,
                               "_test_database_oracle_managed_files",
                               return_value=True):
            with self.patch_execute_statements(_execute_capture_statements):
                with connection.cursor() as cursor:
                    creation._execute_test_db_creation(
                        cursor, creation._get_test_db_params(), verbosity=0)
                    tblspace_sql, tblspace_tmp_sql = creation.tblspace_sqls
                    # Datafile names shouldn't appear.
                    self.assertIn("DATAFILE SIZE", tblspace_sql)
                    self.assertIn("TEMPFILE SIZE", tblspace_tmp_sql)
                    # REUSE cannot be used with OMF.
                    self.assertNotIn("REUSE", tblspace_sql)
                    self.assertNotIn("REUSE", tblspace_tmp_sql)
Exemplo n.º 2
0
 def test_create_test_db(self, *mocked_objects):
     creation = DatabaseCreation(connection)
     # Simulate test database creation raising "tablespace already exists"
     with self.patch_execute_statements(self._execute_raise_tablespace_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 tablespace.
                 creation._create_test_db(verbosity=0, keepdb=False)
         # "Tablespace already exists" error is ignored when keepdb is on
         creation._create_test_db(verbosity=0, keepdb=True)
     # Simulate test database creation raising unexpected error
     with self.patch_execute_statements(self._execute_raise_insufficient_privileges):
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, keepdb=False)
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, keepdb=True)
Exemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super(DatabaseWrapper, self).__init__(*args, **kwargs)

        self.features = DatabaseFeatures()
        self.ops = DatabaseOperations()
        self.client = DatabaseClient(self)
        self.creation = DatabaseCreation(self)
        self.introspection = DatabaseIntrospection(self)
        self.validation = BaseDatabaseValidation(self)
Exemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        super(DatabaseWrapper, self).__init__(*args, **kwargs)

        self.features = DatabaseFeatures(self)
        use_returning_into = self.settings_dict["OPTIONS"].get('use_returning_into', True)
        self.features.can_return_id_from_insert = use_returning_into
        self.ops = DatabaseOperations(self)
        self.client = DatabaseClient(self)
        self.creation = DatabaseCreation(self)
        self.introspection = DatabaseIntrospection(self)
        self.validation = BaseDatabaseValidation(self)
Exemplo n.º 5
0
 def test_create_test_db(self, *mocked_objects):
     creation = OracleDatabaseCreation(connection)
     # Simulate test database creation raising "tablespace already exists"
     with self.patch_execute_statements(self._execute_raise_tablespace_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 tablespace.
                 creation._create_test_db(verbosity=0, keepdb=False)
         # "Tablespace already exists" error is ignored when keepdb is on
         creation._create_test_db(verbosity=0, keepdb=True)
     # Simulate test database creation raising unexpected error
     with self.patch_execute_statements(self._execute_raise_insufficient_privileges):
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, keepdb=False)
         with self.assertRaises(SystemExit):
             creation._create_test_db(verbosity=0, keepdb=True)
Exemplo n.º 6
0
 def test_create_test_user(self, *mocked_objects):
     creation = DatabaseCreation(connection)
     with mock.patch.object(DatabaseCreation, "_test_database_passwd",
                            self._test_database_passwd):
         # Simulate test user creation raising "user already exists"
         with self.patch_execute_statements(
                 self._execute_raise_user_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 user.
                     creation._create_test_db(verbosity=0, keepdb=False)
             # "User already exists" error is ignored when keepdb is on
             creation._create_test_db(verbosity=0, keepdb=True)
         # Simulate test user creation raising unexpected error
         with self.patch_execute_statements(
                 self._execute_raise_insufficient_privileges):
             with self.assertRaises(SystemExit):
                 creation._create_test_db(verbosity=0, keepdb=False)
             with self.assertRaises(SystemExit):
                 creation._create_test_db(verbosity=0, keepdb=True)
Exemplo n.º 7
0
 def __init__(self, connection):
     OracleDatabaseCreation.__init__(self, connection)
     
     ascii_data_types = get_ascii_data_types(self.connection.settings_dict)
     if ascii_data_types:
         data_types = ascii_data_types