MCPcopy
hub / github.com/django/django / _create_test_user

Method _create_test_user

django/db/backends/oracle/creation.py:268–306  ·  view source on GitHub ↗
(self, cursor, parameters, verbosity, keepdb=False)

Source from the content-addressed store, hash-verified

266 )
267
268 def _create_test_user(self, cursor, parameters, verbosity, keepdb=False):
269 if verbosity >= 2:
270 self.log("_create_test_user(): username = %s" % parameters["user"])
271 statements = [
272 """CREATE USER %(user)s
273 IDENTIFIED BY "%(password)s"
274 DEFAULT TABLESPACE %(tblspace)s
275 TEMPORARY TABLESPACE %(tblspace_temp)s
276 QUOTA UNLIMITED ON %(tblspace)s
277 """,
278 """GRANT CREATE SESSION,
279 CREATE TABLE,
280 CREATE SEQUENCE,
281 CREATE PROCEDURE,
282 CREATE TRIGGER
283 TO %(user)s""",
284 ]
285 # Ignore "user already exists" error when keepdb is on
286 acceptable_ora_err = "ORA-01920" if keepdb else None
287 success = self._execute_allow_fail_statements(
288 cursor, statements, parameters, verbosity, acceptable_ora_err
289 )
290 # If the password was randomly generated, change the user accordingly.
291 if not success and self._test_settings_get("PASSWORD") is None:
292 set_password = 'ALTER USER %(user)s IDENTIFIED BY "%(password)s"'
293 self._execute_statements(cursor, [set_password], parameters, verbosity)
294 # Most test suites can be run without "create view" and
295 # "create materialized view" privileges. But some need it.
296 for object_type in ("VIEW", "MATERIALIZED VIEW"):
297 extra = "GRANT CREATE %(object_type)s TO %(user)s"
298 parameters["object_type"] = object_type
299 success = self._execute_allow_fail_statements(
300 cursor, [extra], parameters, verbosity, "ORA-01031"
301 )
302 if not success and verbosity >= 2:
303 self.log(
304 "Failed to grant CREATE %s permission to test user. This may be ok."
305 % object_type
306 )
307
308 def _execute_test_db_destruction(self, cursor, parameters, verbosity):
309 if verbosity >= 2:

Callers 1

_create_test_dbMethod · 0.95

Calls 4

_test_settings_getMethod · 0.95
_execute_statementsMethod · 0.95
logMethod · 0.45

Tested by

no test coverage detected