示例#1
0
def test_django_admin_media_serving_on_django_125():
    'lettuce should serve admin static files properly on Django 1.2.5'

    os.environ['PYTHONPATH'] = "%s:%s" % (
        FileSystem.join(lib_directory, 'Django-1.2.5'),
        OLD_PYTHONPATH,
    )
    FileSystem.pushd(current_directory, "django", "grocery")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=2 ./features/")

    assert_equals(status, 0, out)
    FileSystem.popd()

    lines = out.splitlines()
    f = '\n\n'
    f += '*' * 100
    f += '\n' + '\n'.join(lines)

    assert u"Preparing to serve django's admin site static files..." in lines, f
    assert u"Django's builtin server is running at 0.0.0.0:7000" in lines, f
    assert u'Running on port 7000 ... OK' in lines, f
    assert u'Fetching admin media ... OK' in lines, f
    assert u'Fetching static files ... OK' in lines, f
    assert u'Fetching CSS files: ... OK' in lines, f
    assert u'Fetching javascript files: ... OK' in lines, f
示例#2
0
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    FileSystem.pushd(current_directory, "django", "celeries")

    status, output = commands.getstatusoutput("python manage.py harvest --verbosity=3 --failfast")

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain("Celeries before feature 'Test the django app leaves'")
    the(output).should.contain("Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain("Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")

    FileSystem.popd()
示例#3
0
def test_django_admin_media_serving_forced_by_setting():
    'settings.LETTUCE_SERVE_ADMIN_MEDIA forces lettuce to serve admin assets'

    os.environ['PYTHONPATH'] = "%s:%s" % (
        FileSystem.join(lib_directory, 'Django-1.3'),
        OLD_PYTHONPATH,
    )

    FileSystem.pushd(current_directory, "django", "grocery")

    extra_args = " --scenarios=1,3,4,5 --settings=settings_without_admin"

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=2 ./features/ %s" % extra_args)

    assert_equals(status, 0, out)
    FileSystem.popd()

    lines = out.splitlines()

    assert u"Preparing to serve django's admin site static files " \
           "(as per settings.LETTUCE_SERVE_ADMIN_MEDIA=True)..." in lines
    assert u'Running on port 7000 ... OK' in lines
    assert u'Fetching static files ... OK' in lines
    assert u'Fetching CSS files: ... OK' in lines
    assert u'Fetching javascript files: ... OK' in lines
    assert u"Django's builtin server is running at 0.0.0.0:7000" in lines

    # the scenario 2 is not suppose to run
    assert u'Fetching admin media ... OK' not in lines
示例#4
0
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    FileSystem.pushd(current_directory, "django", "celeries")

    status, output = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --failfast")

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain(
        "Celeries before feature 'Test the django app leaves'")
    the(output).should.contain(
        "Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain(
        "Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")

    FileSystem.popd()
示例#5
0
def test_non_recursive_locate():
    fs = FileSystem()
    files = fs.locate(path=abspath(join(dirname(__file__), "files_to_locate")), match="*.txt", recursive=False)

    assert files
    assert isinstance(files, list)
    assert len(files) == 1
    assert split(files[0])[-1] == "test.txt"
示例#6
0
def test_no_server():
    '"harvest" --no-server does not start the server'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --apps=foobar --no-server")

    assert_equals(status, 0, out)
    assert "Django's builtin server is running at" not in out
示例#7
0
def test_django_agains_alfaces():
    'running the "harvest" django command with verbosity 3'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3")
    assert_equals(status, 0)

    FileSystem.popd()
示例#8
0
def test_harvest_sets_environment_variabled_for_gae():
    'harvest sets environment variables SERVER_NAME and SERVER_PORT in order to work with google app engine'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput("python manage.py harvest leaves/features/appengine.feature")
    assert_equals(status, 0, out)

    FileSystem.popd()
示例#9
0
def test_server_threading():
    """
    Test django httpd threading
    """
    FileSystem.pushd(current_directory, "django", "coconut")
    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=1")

    assert_equals(status, 0, out)
示例#10
0
def test_no_server():
    '"harvest" --no-server does not start the server'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --apps=foobar --no-server")

    assert_equals(status, 0)
    assert "Django's builtin server is running at" not in out
示例#11
0
def test_harvest_with_debug_mode_disabled():
    'python manage.py harvest without turns settings.DEBUG=False'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput("python manage.py harvest leaves/features/disabled.feature")
    assert_equals(status, 0, out)

    FileSystem.popd()
示例#12
0
def test_server_threading():
    """
    Test django httpd threading
    """
    FileSystem.pushd(current_directory, "django", "coconut")
    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=1")
    
    assert_equals(status, 0, out)
示例#13
0
def test_django_against_cucumber_django_project():
    'testing all django hooks'

    FileSystem.pushd(current_directory, "django", "cucumber")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=1")

    assert "before harvest" in out
    assert "after harvest" in out
    FileSystem.popd()
示例#14
0
def test_django_no_test_database_option():
    'test whether no test database is used if not wanted'

    FileSystem.pushd(current_directory, "django", "grocery")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=2 --no-test-database ./features/")
    assert_equals(status, 0)
    FileSystem.popd()

    assert_equals(re.match(r".*Creating test database for alias '\w+'\.\.\..*",out), None)
示例#15
0
def test_harvest_with_debug_mode_disabled():
    'python manage.py harvest without turns settings.DEBUG=False'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput(
        "python manage.py harvest leaves/features/disabled.feature")
    assert status is 0

    FileSystem.popd()
示例#16
0
def test_model_creation():
    'Models are created through Lettuce steps'

    FileSystem.pushd(current_directory, "django", "dill")

    status, out = commands.getstatusoutput(
            "python manage.py harvest -T leaves/features/create.feature")
    assert_equals(status, 0, out)

    FileSystem.popd()
示例#17
0
def test_django_agains_couves():
    'it always call @after.all hooks, even after exceptions'

    FileSystem.pushd(current_directory, "django", "couves")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3")

    assert "Couves before all" in out
    assert "Couves after all" in out
    FileSystem.popd()
示例#18
0
def test_model_creation():
    'Models are created through Lettuce steps'

    FileSystem.pushd(current_directory, "django", "dill")

    status, out = commands.getstatusoutput(
        "python manage.py harvest -T leaves/features/create.feature")
    assert_equals(status, 0, out)

    FileSystem.popd()
示例#19
0
def test_harvest_sets_environment_variabled_for_gae():
    'harvest sets environment variables SERVER_NAME and SERVER_PORT in order to work with google app engine'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput(
        "python manage.py harvest leaves/features/appengine.feature")
    assert status is 0

    FileSystem.popd()
示例#20
0
def test_limit_by_app_getting_all_apps_by_comma():
    'running "harvest" with --apps=multiple,apps,separated,by,comma'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --apps=foobar,donothing")
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
    FileSystem.popd()
示例#21
0
def test_django_agains_alfaces():
    'running the "harvest" django command with verbosity 3'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3")
    assert_equals(status, 0)

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
    FileSystem.popd()
示例#22
0
def test_running_only_specified_features():
    'it can run only the specified features, passing the file path'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 foobar/features/foobar.feature")
    assert_equals(status, 0)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
    FileSystem.popd()
示例#23
0
def test_harvest_uses_test_runner():
    'harvest uses LETTUCE_TEST_SERVER specified in settings'

    FileSystem.pushd(current_directory, "django", "kale")

    status, out = commands.getstatusoutput(
        "python manage.py harvest -T leaves/features/modification.feature")

    assert_equals(status, 0, out)

    FileSystem.popd()
示例#24
0
def test_limit_by_app_getting_all_apps_by_comma():
    'running "harvest" with --apps=multiple,apps,separated,by,comma'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --apps=foobar,donothing")
    assert_equals(status, 0)

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
    FileSystem.popd()
示例#25
0
def test_running_only_apps_within_lettuce_apps_setting():
    'running the "harvest" will run only on configured apps if the setting LETTUCE_APPS is set'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=onlyfoobarsettings --verbosity=3")
    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
    FileSystem.popd()
示例#26
0
def test_excluding_apps_separated_by_comma():
    'running "harvest" with --avoid-apps=multiple,apps'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --avoid-apps=donothing,foobar")
    assert_equals(status, 0)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" not in out
    FileSystem.popd()
示例#27
0
def test_excluding_app():
    'running "harvest" with --avoid-apps=one_app'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --avoid-apps=donothing")
    assert_equals(status, 0)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
    FileSystem.popd()
示例#28
0
def test_running_only_specified_features():
    'it can run only the specified features, passing the file path'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 foobar/features/foobar.feature")
    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
    FileSystem.popd()
示例#29
0
def test_running_only_apps_within_lettuce_apps_setting():
    'running the "harvest" will run only on configured apps if the setting LETTUCE_APPS is set'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=onlyfoobarsettings --verbosity=3")
    assert_equals(status, 0)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
    FileSystem.popd()
示例#30
0
def test_excluding_app():
    'running "harvest" with --avoid-apps=one_app'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --avoid-apps=donothing")
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
    FileSystem.popd()
示例#31
0
def test_running_all_apps_but_lettuce_avoid_apps():
    'running the "harvest" will run all apps but those within LETTUCE_AVOID_APPS'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=allbutfoobarsettings --verbosity=3")
    assert_equals(status, 0)

    assert "Test the django app FOO BAR" not in out
    assert "Test the django app DO NOTHING" in out
    FileSystem.popd()
示例#32
0
def test_running_all_apps_but_lettuce_avoid_apps():
    'running the "harvest" will run all apps but those within LETTUCE_AVOID_APPS'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=allbutfoobarsettings --verbosity=3")
    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" not in out
    assert "Test the django app DO NOTHING" in out
    FileSystem.popd()
示例#33
0
def test_django_against_cucumber_django_project():
    'testing all django hooks'

    FileSystem.pushd(current_directory, "django", "cucumber")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=1")

    assert "before harvest" in out
    assert "after harvest" in out
    FileSystem.popd()
示例#34
0
def test_harvest_with_debug_mode_enabled():
    'python manage.py harvest -d turns settings.DEBUG=True'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput("python manage.py harvest -d leaves/features/enabled.feature")
    assert status is 0
    status, out = commands.getstatusoutput("python manage.py harvest --debug-mode leaves/features/enabled.feature")
    assert status is 0

    FileSystem.popd()
示例#35
0
def test_django_agains_couves_nohooks():
    'it only calls @before.all and @after.all hooks if there are features found'

    FileSystem.pushd(current_directory, "django", "couves")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --tags=nothingwillbefound")

    expect("Couves before all").to.not_be.within(out)
    expect("Couves after all").to.not_be.within(out)
    FileSystem.popd()
示例#36
0
def test_server_threading():
    """
    Test django httpd threading
    """
    python_path = sys.executable

    FileSystem.pushd(current_directory, "django", "coconut")
    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=1" % (python_path,))

    assert_equals(status, 0, out)
示例#37
0
def test_excluding_apps_separated_by_comma():
    'running "harvest" with --avoid-apps=multiple,apps'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --avoid-apps=donothing,foobar")
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" not in out
    FileSystem.popd()
示例#38
0
def test_ignores_settings_avoid_apps_if_apps_argument_is_passed():
    'even if all apps are avoid in settings, it is possible to run a single app ' \
    'by --apps argument'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=avoidallappssettings --verbosity=3 --apps=foobar,donothing")
    assert_equals(status, 0)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" in out
    FileSystem.popd()
示例#39
0
def test_ignores_settings_avoid_apps_if_apps_argument_is_passed():
    'even if all apps are avoid in settings, it is possible to run a single app ' \
    'by --apps argument'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --settings=avoidallappssettings --verbosity=3 --apps=foobar,donothing")
    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" in out
    FileSystem.popd()
示例#40
0
def test_harvest_uses_test_runner():
    'harvest uses TEST_RUNNER specified in settings'

    FileSystem.pushd(current_directory, "django", "brocolis")

    status, out = commands.getstatusoutput(
        "python manage.py harvest -T leaves/features/disabled.feature")

    assert_equals(status, 0, out)
    assert "Custom test runner enabled." in out

    FileSystem.popd()
示例#41
0
def test_django_admin_media_serving():
    'serving admin media in django projects that have "admin" in INSTALLED_APPS'

    FileSystem.pushd(current_directory, "django", "grocery")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 ./features/")
    assert_equals(status, 0)
    FileSystem.popd()

    lines = out.splitlines()
    assert_equals(lines[0], u"Preparing to server django's admin site static files...")
    assert_equals(lines[1], u"Django's builtin server is running at 0.0.0.0:8000")
示例#42
0
def test_django_admin_media_serving():
    'serving admin media in django projects that have "admin" in INSTALLED_APPS'

    FileSystem.pushd(current_directory, "django", "grocery")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 ./features/")
    assert_equals(status, 0, out)
    FileSystem.popd()

    lines = out.splitlines()

    assert u"Preparing to serve django's admin site static files..." in lines
    assert u"Django's builtin server is running at 0.0.0.0:7000" in lines
示例#43
0
def test_harvest_with_debug_mode_enabled():
    'python manage.py harvest -d turns settings.DEBUG=True'

    FileSystem.pushd(current_directory, "django", "brocolis")

    for option in ['-d', '--debug-mode']:
        status, out = commands.getstatusoutput(
            "python manage.py harvest %s " \
            "leaves/features/enabled.feature" % option,
        )
        assert_equals(status, 0, out)

    FileSystem.popd()
示例#44
0
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()
示例#45
0
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()
示例#46
0
def test_django_admin_media_serving():
    'serving admin media in django projects that have "admin" in INSTALLED_APPS'

    FileSystem.pushd(current_directory, "django", "grocery")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=2 ./features/")
    assert_equals(status, 0)
    FileSystem.popd()

    lines = out.splitlines()

    assert_not_equals(re.match(r"Creating test database for alias '\w+'\.\.\.",lines[0]), None)
    assert_equals(lines[1], u"Preparing to server django's admin site static files...")
    assert_not_equals(re.match(r"Django's builtin server is running at 0\.0\.0\.0:\d+",lines[2]), None)
示例#47
0
def test_specifying_features_in_inner_directory():
    'it can run only the specified features from a subdirectory'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 " \
        "foobar/features/deeper/deeper/leaf.feature")

    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" not in out
    assert "Test a feature in an inner directory" in out
    assert "Test the django app DO NOTHING" not in out
    FileSystem.popd()
示例#48
0
def test_django_admin_media_serving_forced_by_setting():
    'settings.LETTUCE_SERVE_ADMIN_MEDIA forces lettuce to serve admin assets'

    os.environ['PYTHONPATH'] = "%s:%s" % (
        FileSystem.join(lib_directory, 'Django-1.3'),
        OLD_PYTHONPATH,
    )

    extra_args = " --scenarios=1,3,4,5 --settings=settings_without_admin"

    status, out = subprocess.getstatusoutput(
        "python manage.py harvest --verbosity=2 ./features/ %s" % extra_args)

    assert_equals(status, 0, out)

    lines = out.splitlines()

    assert "Preparing to serve django's admin site static files " \
           "(as per settings.LETTUCE_SERVE_ADMIN_MEDIA=True)..." in lines
    assert 'Running on port 7000 ... OK' in lines
    assert 'Fetching static files ... OK' in lines
    assert 'Fetching CSS files: ... OK' in lines
    assert 'Fetching javascript files: ... OK' in lines
    assert "Django's builtin server is running at 0.0.0.0:7000" in lines

    # the scenario 2 is not suppose to run
    assert 'Fetching admin media ... OK' not in lines
示例#49
0
def test_django_admin_media_serving_on_django_125():
    'lettuce should serve admin static files properly on Django 1.2.5'

    os.environ['PYTHONPATH'] = "%s:%s" % (
        FileSystem.join(lib_directory, 'Django-1.2.5'),
        OLD_PYTHONPATH,
    )

    status, out = subprocess.getstatusoutput(
        "python manage.py harvest --verbosity=2 ./features/")

    assert_equals(status, 0, out)

    lines = out.splitlines()
    f = '\n\n'
    f += '*' * 100
    f += '\n' + '\n'.join(lines)

    assert "Preparing to serve django's admin site static files..." in lines, f
    assert "Django's builtin server is running at 0.0.0.0:7000" in lines, f
    assert 'Running on port 7000 ... OK' in lines, f
    assert 'Fetching admin media ... OK' in lines, f
    assert 'Fetching static files ... OK' in lines, f
    assert 'Fetching CSS files: ... OK' in lines, f
    assert 'Fetching javascript files: ... OK' in lines, f
示例#50
0
def test_django_specifying_scenarios_to_run():
    'django harvest can run only specified scenarios with --scenarios or -s options'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --scenarios=2,5 -a foobar")
    assert_equals(status, 0)

    assert "2nd scenario" in out
    assert "5th scenario" in out

    assert "1st scenario" not in out
    assert "3rd scenario" not in out
    assert "4th scenario" not in out
    assert "6th scenario" not in out

    FileSystem.popd()
示例#51
0
def test_django_specifying_scenarios_to_run():
    'django harvest can run only specified scenarios with --scenarios or -s options'

    FileSystem.pushd(current_directory, "django", "alfaces")

    status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --scenarios=2,5 -a foobar")
    assert_equals(status, 0, out)

    assert "2nd scenario" in out
    assert "5th scenario" in out

    assert "1st scenario" not in out
    assert "3rd scenario" not in out
    assert "4th scenario" not in out
    assert "6th scenario" not in out

    FileSystem.popd()
示例#52
0
def test_model_existence_check():
    'Model existence is checked through Lettuce steps'

    def run_scenario(scenario):
        return commands.getstatusoutput(
            "python manage.py harvest -v 3 -T " +
            "leaves/features/existence.feature -s %d" % scenario)

    FileSystem.pushd(current_directory, "django", "dill")

    status, out = run_scenario(1)
    assert_equals(status, 0, out)

    status, out = run_scenario(2)
    assert_not_equals(status, 0)
    assert "Garden does not exist: {u'name': u'Botanic Gardens'}" in out
    gardens = "\n".join([
        "Rows in DB are:",
        "id=1, name=Secret Garden, area=45, raining=False,",
        "id=2, name=Octopus's Garden, area=120, raining=True,",
        "id=3, name=Covent Garden, area=200, raining=True,",
    ])
    assert gardens in out
    assert "AssertionError: 1 rows missing" in out

    status, out = run_scenario(3)
    assert_not_equals(status, 0)
    assert "Garden does not exist: {u'name': u'Secret Garden', " \
        "u'@howbig': u'huge'}" in out
    gardens = "\n".join([
        "Rows in DB are:",
        "id=1, name=Secret Garden, area=45, raining=False, howbig=small,",
        "id=2, name=Octopus's Garden, area=120, raining=True, howbig=medium,",
        "id=3, name=Covent Garden, area=200, raining=True, howbig=big,",
    ])
    assert gardens in out
    assert "AssertionError: 1 rows missing" in out

    status, out = run_scenario(4)
    assert_not_equals(status, 0)
    assert "Expected 2 geese, found 1" in out

    FileSystem.popd()
示例#53
0
def test_django_admin_media_serving_on_django_13():
    'lettuce should serve admin static files properly on Django 1.3'

    os.environ['PYTHONPATH'] = "%s:%s" % (
        FileSystem.join(lib_directory, 'Django-1.3'),
        OLD_PYTHONPATH,
    )

    FileSystem.pushd(current_directory, "django", "chive")

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=2 ./features/")

    assert_not_equals(status, 0)
    FileSystem.popd()

    lines = out.splitlines()

    assert u"Preparing to serve django's admin site static files..." in lines
    assert u"Django's builtin server is running at 0.0.0.0:7000" in lines
示例#54
0
def test_django_background_server_running_in_background_with_custom_port():
    'the harvest command should take a --port argument'

    FileSystem.pushd(current_directory, "django", "alfaces")

    import tornado.ioloop
    import tornado.web

    class MainHandler(tornado.web.RequestHandler):
        def get(self):
            self.write("Hello, world")
            raise SystemExit()

    def runserver():
        application = tornado.web.Application([
            (r"/", MainHandler),
        ])
        application.listen(9889)
        tornado.ioloop.IOLoop.instance().start()

    server = multiprocessing.Process(target=runserver)
    server.start()
    time.sleep(1)  # the child process take some time to get up

    e = 'Lettuce could not run the builtin Django server at 0.0.0.0:9889"\n' \
        'maybe you forgot a "runserver" instance running ?\n\n' \
        'well if you really do not want lettuce to run the server ' \
        'for you, then just run:\n\n' \
        'python manage.py --no-server'

    try:
        status, out = commands.getstatusoutput(
            "python manage.py harvest --verbosity=3 --port=9889")
        assert_equals(out, e)
        assert_not_equals(status, 0)

    finally:
        os.kill(server.pid, 9)
        FileSystem.popd()