Example #1
0
def test_model_existence_check():
    'Model existence is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'existence', 1)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'existence', 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('leaves', 'existence', 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('leaves', 'existence', 4)
    assert_not_equals(status, 0)
    assert "Expected 2 geese, found 1" in out
Example #2
0
def test_model_existence_check():
    'Model existence is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'existence', 1)
    assert_equals(status, 0, out)

    garden4 = '颐和园'

    status, out = run_scenario('leaves', 'existence', 2)
    assert_not_equals(status, 0)
    assert_in("Garden does not exist: {0}".format({'name': 'Botanic Gardens'}),
              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",
        "id=4, name={}, area=500, raining=False".format(garden4),
    ])

    assert_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 3)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden does not exist: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'huge'})[1:-1], 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",
        "id=4, name={}, area=500, raining=False, howbig=big".format(garden4),
    ])
    assert_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 4)
    assert_not_equals(status, 0)
    assert_in("Expected 2 geese, found 1", out)

    status, out = run_scenario('leaves', 'existence', 5)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden exists: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'small'})[1:-1], out)
    assert_in("AssertionError: 1 rows found", 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",
        "id=4, name={}, area=500, raining=False, howbig=big".format(garden4),
    ])
    assert_in(gardens, out)
Example #3
0
def test_mail_content_html():
    """Test steps for checking HTML email content."""

    status, out = run_scenario('leaves', 'content', 3)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 6)
    assert_not_equals(status, 0)
    assert_in("No email contained the HTML", out)
def test_mail_content_html():
    """Test steps for checking HTML email content."""

    status, out = run_scenario('leaves', 'content', 3)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 6)
    assert_not_equals(status, 0)
    assert_in("No email contained the HTML", out)
def test_model_existence_check():
    'Model existence is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'existence', 1)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'existence', 2)
    assert_not_equals(status, 0)
    assert_in(
        "Garden does not exist: {0}".format(
            {'name': 'Botanic Gardens'}
        ),
        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_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 3)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden does not exist: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'huge'})[1:-1], 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_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 4)
    assert_not_equals(status, 0)
    assert_in("Expected 2 geese, found 1", out)

    status, out = run_scenario('leaves', 'existence', 5)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden exists: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'small'})[1:-1], out)
    assert_in("AssertionError: 1 rows found", 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_in(gardens, out)
Example #6
0
def test_mail_content():
    'Mail content is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'content', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'content', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 3)
    assert_not_equals(status, 0)
    assert "An email contained expected text in the body" in out
Example #7
0
def test_mail_count():
    'Mail count is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'count', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'count', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'count', 3)
    assert_not_equals(status, 0)
    assert "Length of outbox is 1" in out
Example #8
0
def test_mail_count():
    'Mail count is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'count', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'count', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'count', 3)
    assert_not_equals(status, 0)
    assert_in("Expected to send 1 email(s), got 2.", out)
Example #9
0
def test_mail_content():
    "Mail content is checked through Lettuce steps"

    status, out = run_scenario("leaves", "content", 1)
    assert_equals(status, 0, out)
    status, out = run_scenario("leaves", "content", 2)
    assert_equals(status, 0, out)

    status, out = run_scenario("leaves", "content", 3)
    assert_not_equals(status, 0)
    assert "An email contained expected text in the body" in out
Example #10
0
def test_mail_content():
    'Mail content is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'content', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'content', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 3)
    assert_not_equals(status, 0)
    assert "An email contained expected text in the body" in out
Example #11
0
def test_mail_count():
    "Mail count is checked through Lettuce steps"

    status, out = run_scenario("leaves", "count", 1)
    assert_equals(status, 0, out)
    status, out = run_scenario("leaves", "count", 2)
    assert_equals(status, 0, out)

    status, out = run_scenario("leaves", "count", 3)
    assert_not_equals(status, 0)
    assert "Length of outbox is 1" in out
def test_mail_count():
    'Mail count is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'count', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'count', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'count', 3)
    assert_not_equals(status, 0)
    assert_in("Expected to send 1 email(s), got 2.", out)
def test_mail_count():
    'Mail count is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'count', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'count', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'count', 3)
    assert_not_equals(status, 0)
    assert_in("Length of outbox is 1", out)
def test_mail_content_html():
    """Test steps for checking HTML email content."""

    import django
    from unittest import SkipTest
    if django.VERSION < (1, 4):
        raise SkipTest("HTML check steps are only available on Django 1.4+")

    status, out = run_scenario('leaves', 'content', 3)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 6)
    assert_not_equals(status, 0)
    assert_in("No email contained the HTML", out)
Example #15
0
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    status, output = run_scenario(**{'--failfast': None})

    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")
Example #16
0
def test_run_with_tags_and_features():
    """it will only run specified tags in the feature files"""

    status, out = run_scenario('donothing', attr='!passes,!fails')

    assert_equals(status, 0, out)
    assert_in("Ran 1 test", out)
Example #17
0
def test_run_with_tags():
    """it will only run specified tags"""

    status, out = run_scenario(attr='!fails')

    assert_equals(status, 0, out)
    assert_in("Ran 2 tests", out)
Example #18
0
def test_django_against_cucumber_django_project():
    'testing all django hooks'

    status, out = run_scenario()

    assert "before harvest" in out
    assert "after harvest" in out
Example #19
0
def test_django_agains_couves_nohooks():
    'it only calls @before.all and @after.all hooks if there are features found'

    status, out = run_scenario(**{'--tags': 'nothingwillbefound'})

    expect("Couves before all").to.not_be.within(out)
    expect("Couves after all").to.not_be.within(out)
Example #20
0
def test_harvest_uses_test_runner():
    'harvest uses TEST_RUNNER specified in settings'

    status, out = run_scenario('leaves', 'disabled')

    assert_equals(status, 0, out)
    assert "Custom test runner enabled." in out
Example #21
0
def test_model_update():
    'Models are updated through Lettuce steps'

    status, out = run_scenario('leaves', 'update', 1)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'update', 2)
    assert_not_equals(status, 0, out)
    assert_in("IntegrityError", out)

    status, out = run_scenario('leaves', 'update', 3)
    assert_not_equals(status, 0, out)
    assert_in("The \"pk\" field is required for all update operations", out)

    status, out = run_scenario('leaves', 'update', 4)
    assert_equals(status, 0, out)
Example #22
0
def test_django_agains_couves():
    'it always call @after.all hooks, even after exceptions'

    _, out = run_scenario(**{'-s': None})

    assert_in("Couves before all", out)
    assert_in("Couves after all", out)
Example #23
0
def test_django_agains_couves():
    'it always call @after.all hooks, even after exceptions'

    status, out = run_scenario()

    expect("Couves before all").to.be.within(out)
    expect("Couves after all").to.be.within(out)
Example #24
0
def test_django_agains_alfaces():
    """running the "harvest" django command with verbosity 3"""

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

    assert_in("Test the django app DO NOTHING", out)
    assert_in("Test the django app FOO BAR", out)
Example #25
0
def test_model_update():
    'Models are updated through Lettuce steps'

    status, out = run_scenario('leaves', 'update', 1)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'update', 2)
    assert_not_equals(status, 0, out)
    assert "IntegrityError: PRIMARY KEY must be unique" in out

    status, out = run_scenario('leaves', 'update', 3)
    assert_not_equals(status, 0, out)
    assert "The \"pk\" field is required for all update operations" in out

    status, out = run_scenario('leaves', 'update', 4)
    assert_not_equals(status, 0, out)
    assert "Must use the writes_models decorator to update models" in out
Example #26
0
def test_running_only_specified_features():
    """it can run only the specified features, passing the file path"""

    status, out = run_scenario('foobar', 'foobar')

    assert_equals(status, 0, out)

    assert_in("Test the django app FOO BAR", out)
    assert_not_in("Test the django app DO NOTHING", out)
Example #27
0
def test_specifying_features_in_inner_directory():
    """it can run only the specified features from a subdirectory"""

    status, out = run_scenario('foobar', 'deeper/deeper/leaf')

    assert_equals(status, 0, out)

    assert_not_in("Test the django app FOO BAR", out)
    assert_in("Test a feature in an inner directory", out)
    assert_not_in("Test the django app DO NOTHING", out)
def test_mail_content():
    'Mail content is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'content', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'content', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 4)
    assert_not_equals(status, 0)
    assert_in("No email contained expected text in the body.", out)
    assert_in("Sent emails:", out)
    assert_in("Order ID: 10\nName: Fluffy Bear\nQuantity: Quite a few", out)

    status, out = run_scenario('leaves', 'content', 5)
    assert_not_equals(status, 0)
    assert_in("An email contained unexpected text in the body.", out)
    assert_in("Sent emails:", out)
    assert_in("Order ID: 10\nName: Fluffy Badger\nQuantity: Quite a few", out)
Example #29
0
def test_mail_content():
    'Mail content is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'content', 1)
    assert_equals(status, 0, out)
    status, out = run_scenario('leaves', 'content', 2)
    assert_equals(status, 0, out)

    status, out = run_scenario('leaves', 'content', 4)
    assert_not_equals(status, 0)
    assert_in("No email contained expected text in the body.", out)
    assert_in("Sent emails:", out)
    assert_in("Order ID: 10\nName: Fluffy Bear\nQuantity: Quite a few", out)

    status, out = run_scenario('leaves', 'content', 5)
    assert_not_equals(status, 0)
    assert_in("An email contained unexpected text in the body.", out)
    assert_in("Sent emails:", out)
    assert_in("Order ID: 10\nName: Fluffy Badger\nQuantity: Quite a few", out)
Example #30
0
def test_django_agains_couves_nohooks():
    """
    it only calls @before.all and @after.all hooks if there are features found
    """

    _, out = run_scenario(**{
        '--tags': 'nothingwillbefound',
        '-s': None,
    })

    assert_not_in("Couves before all", out)
    assert_not_in("Couves after all", out)
Example #31
0
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    status, output = run_scenario(**{'--failfast': None})

    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")
Example #32
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'

    status, out = run_scenario('leaves', 'appengine')
    assert_equals(status, 0, out)
Example #33
0
def test_harvest_with_debug_mode_disabled():
    'python manage.py harvest without turns settings.DEBUG=False'

    status, out = run_scenario('leaves', 'disabled')
    assert_equals(status, 0, out)
Example #34
0
def test_harvest_with_debug_mode_enabled():
    'python manage.py harvest -d turns settings.DEBUG=True'

    for option in ['-d', '--debug-mode']:
        status, out = run_scenario('leaves', 'enabled', **{option: None})
        assert_equals(status, 0, out)
def test_mail_fail():
    'Mock mail failure dies with error'

    status, out = run_scenario('leaves', 'mock-failure', 1)
    assert_not_equals(status, 0)
    assert_in("SMTPException: Failure mocked by aloe", out)
Example #36
0
def test_mail_fail():
    "Mock mail failure dies with error"

    status, out = run_scenario("leaves", "mock-failure", 1)
    assert_not_equals(status, 0)
    assert "SMTPException: Failure mocked by lettuce" in out
Example #37
0
    def test_django_app(self):
        """Create a stock Django app and test running features for it."""

        # Create the project and the application
        subprocess.check_call(('django-admin', 'startproject', 'lychee'))
        os.chdir('lychee')
        subprocess.check_call(('django-admin', 'startapp', 'lychee_app'))

        # Add the created application and Aloe-Django to installed
        with open(find_file('settings.py'), 'a') as settings:
            settings.write("""
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'test.sqlite',
    }
}

INSTALLED_APPS += ('aloe_django', 'lychee_app')
""")

        app_root = find_file('lychee_app')

        # Add a view and a template
        with open(find_file('views.py'), 'a') as views:
            views.write("""
from django.views.generic import TemplateView
class HelloView(TemplateView):
    template_name = 'hello.html'
""")

        templates_dir = os.path.join(app_root, 'templates')
        os.mkdir(templates_dir)
        with open(os.path.join(templates_dir, 'hello.html'), 'w') as template:
            template.write("World!")

        # Add the view to URLs
        with open(find_file('urls.py'), 'a') as urls:
            urls.write("""
from lychee_app.views import HelloView
urlpatterns += [url(r'^hello/', HelloView.as_view())]
""")

        # Create a features directory
        features_dir = os.path.join(app_root, 'features')
        os.mkdir(features_dir)

        # Copy in a feature and steps for it
        for filename in (
                'hello.feature',
                '__init__.py',
                'steps.py',
        ):
            shutil.copyfile(
                os.path.join(SOURCE_DIR, filename),
                os.path.join(features_dir, filename),
            )

        ret, output = run_scenario()

        print(output)

        self.assertEqual(ret, 0, "Should succeed")
        self.assertIn("Ran 1 test", output)
Example #38
0
def test_harvest_uses_test_runner():
    'harvest uses LETTUCE_TEST_SERVER specified in settings'

    status, out = run_scenario()
    assert "Test Suite Summary:" in out
    def test_django_app(self):
        """Create a stock Django app and test running features for it."""

        if django.get_version() >= '1.7':
            django_admin = 'django-admin'
        else:
            django_admin = 'django-admin.py'

        # Create the project and the application
        subprocess.check_call((django_admin, 'startproject', 'lychee'))
        os.chdir('lychee')
        subprocess.check_call((django_admin, 'startapp', 'lychee_app'))

        # Add the created application and Aloe-Django to installed
        with open(find_file('settings.py'), 'a') as settings:
            settings.write("""
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'test.sqlite',
    }
}

INSTALLED_APPS += ('aloe_django', 'lychee_app')
""")

        app_root = find_file('lychee_app')

        # Add a view and a template
        with open(find_file('views.py'), 'a') as views:
            views.write("""
from django.views.generic import TemplateView
class HelloView(TemplateView):
    template_name = 'hello.html'
""")

        templates_dir = os.path.join(app_root, 'templates')
        os.mkdir(templates_dir)
        with open(os.path.join(templates_dir, 'hello.html'), 'w') as template:
            template.write("World!")

        # Add the view to URLs
        with open(find_file('urls.py'), 'a') as urls:
            urls.write("""
from lychee_app.views import HelloView
urlpatterns += [url(r'^hello/', HelloView.as_view())]
""")

        # Create a features directory
        features_dir = os.path.join(app_root, 'features')
        os.mkdir(features_dir)

        # Copy in a feature and steps for it
        for filename in (
                'hello.feature',
                '__init__.py',
                'steps.py',
        ):
            shutil.copyfile(
                os.path.join(SOURCE_DIR, filename),
                os.path.join(features_dir, filename),
            )

        ret, output = run_scenario()

        print(output)

        self.assertEqual(ret, 0, "Should succeed")
        self.assertIn("Ran 1 test", output)
Example #40
0
def test_model_creation():
    'Models are created through Lettuce steps'

    status, out = run_scenario('leaves', 'create')
    assert_equals(status, 0, out)
Example #41
0
def test_harvest_uses_test_runner():
    'harvest uses LETTUCE_TEST_SERVER specified in settings'

    status, out = run_scenario('leaves', 'modification')

    assert_equals(status, 0, out)
Example #42
0
def test_model_existence_check():
    'Model existence is checked through Lettuce steps'

    status, out = run_scenario('leaves', 'existence', 1)
    assert_equals(status, 0, out)

    # One of the gardens has a non-ASCII name. On Python 2 under Django >= 1.9,
    # it gets output by Nose using the escapes.
    garden4 = '颐和园'
    if not PY3 and django.VERSION >= (1, 9):
        garden4 = garden4.encode('unicode_escape')

    status, out = run_scenario('leaves', 'existence', 2)
    assert_not_equals(status, 0)
    assert_in(
        "Garden does not exist: {0}".format(
            {'name': 'Botanic Gardens'}
        ),
        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",
        "id=4, name={}, area=500, raining=False".format(garden4),
    ])

    assert_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 3)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden does not exist: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'huge'})[1:-1], 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",
        "id=4, name={}, area=500, raining=False, howbig=big".format(garden4),
    ])
    assert_in(gardens, out)
    assert_in("AssertionError: 1 rows missing", out)

    status, out = run_scenario('leaves', 'existence', 4)
    assert_not_equals(status, 0)
    assert_in("Expected 2 geese, found 1", out)

    status, out = run_scenario('leaves', 'existence', 5)
    assert_not_equals(status, 0)
    # Cannot check exact string because the order isn't stable
    assert_in("Garden exists: ", out)
    assert_in(str({'name': 'Secret Garden'})[1:-1], out)
    assert_in(str({'@howbig': 'small'})[1:-1], out)
    assert_in("AssertionError: 1 rows found", 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",
        "id=4, name={}, area=500, raining=False, howbig=big".format(garden4),
    ])
    assert_in(gardens, out)
Example #43
0
def test_mail_fail():
    'Mock mail failure dies with error'

    status, out = run_scenario('leaves', 'mock-failure', 1)
    assert_not_equals(status, 0)
    assert "SMTPException: Failure mocked by lettuce" in out