Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
1a6c70a6
Commit
1a6c70a6
authored
Mar 24, 2013
by
Gabriel Falcão
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #335 from RentMethod/master
Django: command option to operate on test database
parents
68ac6d34
80231d4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletions
+30
-1
lettuce/django/management/commands/harvest.py
+30
-1
No files found.
lettuce/django/management/commands/harvest.py
View file @
1a6c70a6
...
...
@@ -18,6 +18,7 @@ import os
import
sys
from
optparse
import
make_option
from
django.conf
import
settings
from
django.core.management
import
call_command
from
django.core.management.base
import
BaseCommand
from
django.test.utils
import
setup_test_environment
from
django.test.utils
import
teardown_test_environment
...
...
@@ -49,6 +50,9 @@ class Command(BaseCommand):
make_option
(
'-S'
,
'--no-server'
,
action
=
'store_true'
,
dest
=
'no_server'
,
default
=
False
,
help
=
"will not run django's builtin HTTP server"
),
make_option
(
'-T'
,
'--test-server'
,
action
=
'store_true'
,
dest
=
'test_database'
,
default
=
False
,
help
=
"will run django's builtin HTTP server using the test databases"
),
make_option
(
'-P'
,
'--port'
,
type
=
'int'
,
dest
=
'port'
,
help
=
"the port in which the HTTP server will run at"
),
...
...
@@ -106,10 +110,30 @@ class Command(BaseCommand):
apps_to_run
=
tuple
(
options
.
get
(
'apps'
,
''
)
.
split
(
","
))
apps_to_avoid
=
tuple
(
options
.
get
(
'avoid_apps'
,
''
)
.
split
(
","
))
run_server
=
not
options
.
get
(
'no_server'
,
False
)
test_database
=
options
.
get
(
'test_database'
,
False
)
tags
=
options
.
get
(
'tags'
,
None
)
failfast
=
options
.
get
(
'failfast'
,
False
)
auto_pdb
=
options
.
get
(
'auto_pdb'
,
False
)
if
test_database
:
migrate_south
=
getattr
(
settings
,
"SOUTH_TESTS_MIGRATE"
,
True
)
try
:
from
south.management.commands
import
patch_for_test_db_setup
patch_for_test_db_setup
()
except
:
migrate_south
=
False
pass
from
django.test.simple
import
DjangoTestSuiteRunner
self
.
_testrunner
=
DjangoTestSuiteRunner
()
self
.
_testrunner
.
setup_test_environment
()
self
.
_old_db_config
=
self
.
_testrunner
.
setup_databases
()
call_command
(
'syncdb'
,
verbosity
=
0
,
interactive
=
False
,)
if
migrate_south
:
call_command
(
'migrate'
,
verbosity
=
0
,
interactive
=
False
,)
server
=
Server
(
port
=
options
[
'port'
])
paths
=
self
.
get_paths
(
args
,
apps_to_run
,
apps_to_avoid
)
...
...
@@ -157,6 +181,11 @@ class Command(BaseCommand):
finally
:
registry
.
call_hook
(
'after'
,
'harvest'
,
results
)
server
.
stop
(
failed
)
if
test_database
:
self
.
_testrunner
.
teardown_databases
(
self
.
_old_db_config
)
teardown_test_environment
()
server
.
stop
(
failed
)
raise
SystemExit
(
int
(
failed
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment