Commit 20e1e1a6 by Alexey Kotlyarov

LETTUCE_USE_TEST_DATABASE setting for always running on a test database

parent 250945fb
...@@ -50,7 +50,8 @@ class Command(BaseCommand): ...@@ -50,7 +50,8 @@ class Command(BaseCommand):
make_option('-S', '--no-server', action='store_true', dest='no_server', default=False, make_option('-S', '--no-server', action='store_true', dest='no_server', default=False,
help="will not run django's builtin HTTP server"), help="will not run django's builtin HTTP server"),
make_option('-T', '--test-server', action='store_true', dest='test_database', default=False, make_option('-T', '--test-server', action='store_true', dest='test_database',
default=getattr(settings, "LETTUCE_USE_TEST_DATABASE", False),
help="will run django's builtin HTTP server using the test databases"), help="will run django's builtin HTTP server using the test databases"),
make_option('-P', '--port', type='int', dest='port', make_option('-P', '--port', type='int', dest='port',
......
...@@ -44,3 +44,7 @@ def database_dump(step): ...@@ -44,3 +44,7 @@ def database_dump(step):
@step(r'I have populated the database') @step(r'I have populated the database')
def database_populated(step): def database_populated(step):
pass pass
@step(r'I count the harvesters')
def count_harvesters(step):
print "Harvester count: %d" % Harvester.objects.count()
Feature: Test running with the test database
Scenario: Test running with the test database
Given I have a harvester in the database:
| make |
| Frank |
Then I count the harvesters
from settings import *
LETTUCE_USE_TEST_DATABASE = True
...@@ -76,3 +76,18 @@ def test_model_existence_check(): ...@@ -76,3 +76,18 @@ def test_model_existence_check():
assert "Expected 2 geese, found 1" in out assert "Expected 2 geese, found 1" in out
FileSystem.popd() FileSystem.popd()
def test_use_test_database_setting():
'Test database is recreated each time if LETTUCE_USE_TEST_DATABASE is set'
FileSystem.pushd(current_directory, "django", "dill")
for i in range(1, 2):
status, out = commands.getstatusoutput(
"python manage.py harvest --settings=testdbsettings " +
"leaves/features/testdb.feature")
assert_equals(status, 0, out)
assert "Harvester count: 1" in out, out
FileSystem.popd()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment