예제 #1
0
def test_output_with_success_colorless():
    """Language: pt-br -> success colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path('pt-br', 'success', 'dumb.feature'),
                        verbosity=3)
        runner.run()

    assert_equals(out.getvalue(),
        u"\n"
        u"Funcionalidade: feature burra       # tests/functional/language_specific_features/pt-br/success/dumb.feature:3\n"
        u"  Como um programador               # tests/functional/language_specific_features/pt-br/success/dumb.feature:4\n"
        u"  Eu quero que este teste passe     # tests/functional/language_specific_features/pt-br/success/dumb.feature:5\n"
        u"  Para testar um cenário de sucesso # tests/functional/language_specific_features/pt-br/success/dumb.feature:6\n"
        u"\n"
        u"  #1\n"
        u"  Cenario: Fazer nada               # tests/functional/language_specific_features/pt-br/success/dumb.feature:8\n"
        u"    Dado que eu faço nada           # tests/functional/language_specific_features/pt-br/success/dumb_steps.py:6\n"
        u"\n"
        u"  ----------------------------------------------------------------------------\n"
        u"\n"
        u"1 feature (1 passed)\n"
        u"1 scenario (1 passed)\n"
        u"1 step (1 passed)\n"
    )
예제 #2
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
예제 #3
0
def test_output_of_table_with_success_colorless():
    """Language: pt-br -> success table colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path('pt-br', 'success', 'table.feature'),
                        verbosity=3)
        runner.run()

    assert_equals(out.getvalue(),
        u"\n"
        u"Funcionalidade: feature burra, com tabela      # tests/functional/language_specific_features/pt-br/success/table.feature:3\n"
        u"  Como um programador                          # tests/functional/language_specific_features/pt-br/success/table.feature:4\n"
        u"  Eu quero testar steps com tabelas            # tests/functional/language_specific_features/pt-br/success/table.feature:5\n"
        u"  Para ver o output em pt-br                   # tests/functional/language_specific_features/pt-br/success/table.feature:6\n"
        u"\n"
        u"  #1\n"
        u"  Cenario: Fazer nada, com tabelas :)          # tests/functional/language_specific_features/pt-br/success/table.feature:8\n"
        u"    Dado que eu brinco com os seguintes itens: # tests/functional/language_specific_features/pt-br/success/table_steps.py:6\n"
        u"      | id | description  |\n"
        u"      | 12 | some desc    |\n"
        u"      | 64 | another desc |\n"
        u"\n"
        u"  ----------------------------------------------------------------------------\n"
        u"\n"
        u"1 feature (1 passed)\n"
        u"1 scenario (1 passed)\n"
        u"1 step (1 passed)\n"
    )
예제 #4
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
def test_simple_tables_behave_as_feature():
    "Basic step.behave_as behaviour is working"

    with capture_output() as (out, _):
        Runner(path_to_feature('2nd_table_steps'), verbosity=3).run()

    assert_equals(out.getvalue(),
        "\n"
        "Feature: Multiplication                            # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:2\n"
        "  In order to avoid silly mistakes                 # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:3\n"
        "  Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:4\n"
        "\n"
        "  #1\n"
        "  Scenario: Regular numbers                        # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:6\n"
        "    Given I multiply these numbers:                # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:31\n"
        "      | number |\n"
        "      | 55     |\n"
        "      | 2      |\n"
        "    Then the result should be 110 on the screen    # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:19\n"
        "\n"
        "  ----------------------------------------------------------------------------\n"
        "\n"
        "  #2\n"
        "  Scenario: Shorter version of the scenario above  # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:13\n"
        "    Given I multiply 55 and 2 into the calculator  # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:23\n"
        "    Then the result should be 110 on the screen    # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:19\n"
        "\n"
        "  ----------------------------------------------------------------------------\n"
        "\n"
        "1 feature (1 passed)\n"
        "2 scenarios (2 passed)\n"
        "4 steps (4 passed)\n"
    )
예제 #6
0
def test_output_of_table_with_success_colorless():
    """Language: ja -> success table colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path('ja', 'success', 'table.feature'),
                        verbosity=3)
        runner.run()

    assert_equals(out.getvalue(),
        u"\n"
        u"フィーチャ: テーブル記法                     # tests/functional/language_specific_features/ja/success/table.feature:3\n"
        u"  日本語でのテーブル記法がパスするかのテスト # tests/functional/language_specific_features/ja/success/table.feature:4\n"
        u"\n"
        u"  #1\n"
        u"  シナリオ: 何もしないテーブル               # tests/functional/language_specific_features/ja/success/table.feature:6\n"
        u"    前提 データは以下:                       # tests/functional/language_specific_features/ja/success/table_steps.py:6\n"
        u"      | id | 定義       |\n"
        u"      | 12 | 何かの定義 |\n"
        u"      | 64 | 別の定義   |\n"
        u"\n"
        u"  ----------------------------------------------------------------------------\n"
        u"\n"
        u"1 feature (1 passed)\n"
        u"1 scenario (1 passed)\n"
        u"1 step (1 passed)\n"
    )
예제 #7
0
def test_assert_equals_fails_as_expected():
    """
    Test assert_equals fails as expected
    """

    raise SkipTest("broken")

    original = """1234
1234
456790"""

    expected = """1234
1234
4567890"""

    def assert_with_stream():
        stream = StringIO()
        asserts.assert_equals(original, expected, stream=stream)

    assert_raises(AssertionError, assert_with_stream)

    print stream.getvalue()

    expected = """{t.white}  {t.normal}{t.white}1234{t.normal}
{t.white}  {t.normal}{t.white}1234{t.normal}
{t.red}- {t.normal}{t.red}456790{t.normal}
{t.green}+ {t.normal}{t.green}4567{t.normal}{t.black_on_green}8{t.normal}{t.green}90{t.normal}
""".format(t=term)

    print expected

    asserts.assert_equals(stream.getvalue(), expected)
예제 #8
0
def test_output_of_table_with_success_colorless():
    """Language: ru -> success table colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path("ru", "success", "table.feature"), verbosity=3)
        runner.run()

    assert_equals(
        out.getvalue(),
        u"\n"
        u"Функционал: фича с табличкой                                     # tests/functional/language_specific_features/ru/success/table.feature:3\n"
        u"  Для того, что бы lettuce был надежным                          # tests/functional/language_specific_features/ru/success/table.feature:4\n"
        u"  Как программист                                                # tests/functional/language_specific_features/ru/success/table.feature:5\n"
        u"  Я хочу, что бы тесты с таблицами работали отлично и на русском # tests/functional/language_specific_features/ru/success/table.feature:6\n"
        u"\n"
        u"  #1\n"
        u"  Сценарий: Проверить таблички                                   # tests/functional/language_specific_features/ru/success/table.feature:8\n"
        u"    Когда Пускай имеем таблицу пациентов:                        # tests/functional/language_specific_features/ru/success/table_steps.py:5\n"
        u"      | ФИО        | Диагноз             |\n"
        u"      | Петров ПП  | диарея              |\n"
        u"      | Сидоров НА | хронический снобизм |\n"
        u"\n"
        u"  ----------------------------------------------------------------------------\n"
        u"\n"
        u"1 feature (1 passed)\n"
        u"1 scenario (1 passed)\n"
        u"1 step (1 passed)\n",
    )
예제 #9
0
def test_output_with_success_colorless():
    """
    Language: fr -> success colorless
    """

    with capture_output() as (out, err):
        runner = Runner(join_path('fr', 'success', 'dumb.feature'),
                        verbosity=3)
        runner.run()

    assert_equals(out.getvalue(), u"""
Fonctionnalité: Test complet # tests/functional/language_specific_features/fr/success/dumb.feature:3
  En tant que programmeur    # tests/functional/language_specific_features/fr/success/dumb.feature:4
  Je veux valider les tests  # tests/functional/language_specific_features/fr/success/dumb.feature:5

  #1
  Scénario: On ne fait rien  # tests/functional/language_specific_features/fr/success/dumb.feature:7
    Quand je ne fait rien    # tests/functional/language_specific_features/fr/success/dumb_steps.py:6

  ----------------------------------------------------------------------------

1 feature (1 passed)
1 scenario (1 passed)
1 step (1 passed)
""")
예제 #10
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
예제 #11
0
def test_output_of_table_with_success_colorless():
    """Language: fr -> sucess table colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path('fr', 'success', 'table.feature'), verbosity=3)
        runner.run()

    assert_equals(out.getvalue(), u"""
Fonctionnalité: Test des sorties, avec table        # tests/functional/language_specific_features/fr/success/table.feature:4
  En tant que programmeur                           # tests/functional/language_specific_features/fr/success/table.feature:5
  Je veux tester les sorties de scénario avec table # tests/functional/language_specific_features/fr/success/table.feature:6

  #1
  Scénario: NE rien faire, mais avec des tables     # tests/functional/language_specific_features/fr/success/table.feature:8
    Soit les éléments suivant                       # tests/functional/language_specific_features/fr/success/table_steps.py:6
      | id | élément |
      | 50 | Un      |
      | 59 | 42      |
      | 29 | sieste  |

  ----------------------------------------------------------------------------

1 feature (1 passed)
1 scenario (1 passed)
1 step (1 passed)
""")
예제 #12
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
def test_simple_behave_as_feature():
    """
    Basic step.behave_as behaviour is working
    """

    with capture_output() as (out, _):
        Runner(path_to_feature('1st_normal_steps'), verbosity=3).run()

    assert_equals(out.getvalue(),
        "\n"
        "Feature: Multiplication                            # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:2\n"
        "  In order to avoid silly mistakes                 # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:3\n"
        "  Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:4\n"
        "\n"
        "  #1\n"
        "  Scenario: Regular numbers                        # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:6\n"
        "    Given I have entered 10 into the calculator    # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:11\n"
        "    And I have entered 4 into the calculator       # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:11\n"
        "    When I press multiply                          # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:15\n"
        "    Then the result should be 40 on the screen     # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:19\n"
        "\n"
        "  ----------------------------------------------------------------------------\n"
        "\n"
        "  #2\n"
        "  Scenario: Shorter version of the scenario above  # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:12\n"
        "    Given I multiply 10 and 4 into the calculator  # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:23\n"
        "    Then the result should be 40 on the screen     # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:19\n"
        "\n"
        "  ----------------------------------------------------------------------------\n"
        "\n"
        "1 feature (1 passed)\n"
        "2 scenarios (2 passed)\n"
        "6 steps (6 passed)\n"
    )
예제 #14
0
def test_output_with_success_colorless():
    """Language: ru -> success colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path("ru", "success", "dumb.feature"), verbosity=3)
        runner.run()

    assert_equals(
        out.getvalue(),
        u"\n"
        u"Функционал: тупая фича                # tests/functional/language_specific_features/ru/success/dumb.feature:3\n"
        u"  Чтобы lettuce был более надежным    # tests/functional/language_specific_features/ru/success/dumb.feature:4\n"
        u"  Как программист                     # tests/functional/language_specific_features/ru/success/dumb.feature:5\n"
        u"  Я хочу что бы тест был зеленый      # tests/functional/language_specific_features/ru/success/dumb.feature:6\n"
        u"\n"
        u"  #1\n"
        u"  Сценарий: Ничего не делать          # tests/functional/language_specific_features/ru/success/dumb.feature:8\n"
        u"    Когда Пуская я ничего не делаю    # tests/functional/language_specific_features/ru/success/dumb_steps.py:6\n"
        u"    Тогда я вижу что тест выполняется # tests/functional/language_specific_features/ru/success/dumb_steps.py:10\n"
        u"\n"
        u"  ----------------------------------------------------------------------------\n"
        u"\n"
        u"1 feature (1 passed)\n"
        u"1 scenario (1 passed)\n"
        u"2 steps (2 passed)\n",
    )
예제 #15
0
def test_output_outlines_success_colorless():
    """Language: ru -> success outlines colorless"""

    with capture_output() as (out, err):
        runner = Runner(join_path("ru", "success", "outlines.feature"), verbosity=3)
        runner.run()

    raise SkipTest("broken")

    assert_equals(
        out.getvalue(),
        u"""
Функционал: Проверить вывод структурного сценария                                  # tests/functional/language_specific_features/ru/success/outlines.feature:3
  Как программист                                                                  # tests/functional/language_specific_features/ru/success/outlines.feature:4
  Для того чобы lettuce был надежным                                               # tests/functional/language_specific_features/ru/success/outlines.feature:5
  Я хочу, что бы сценарии со структурой работали на русском                        # tests/functional/language_specific_features/ru/success/outlines.feature:6

  Структура сценария: Заполнить форму                                              # tests/functional/language_specific_features/ru/success/outlines.feature:8
    Пускай я открываю в браузере  "http://sona-studio.com/contacts/"               # tests/functional/language_specific_features/ru/success/outlines_steps.py:12
    Когда я заполняю в поле "Имя" "<имя>"                                          # tests/functional/language_specific_features/ru/success/outlines_steps.py:16
    И я заполняю в поле "Email" "<email>"                                          # tests/functional/language_specific_features/ru/success/outlines_steps.py:24
    И я заполняю в поле "Сообщение" "<сообщение>"                                  # tests/functional/language_specific_features/ru/success/outlines_steps.py:32
    И я нажимаю "Отправить"                                                        # tests/functional/language_specific_features/ru/success/outlines_steps.py:40
    Тогда я получаю сообщение "Спасибо за ваше сообщение"                          # tests/functional/language_specific_features/ru/success/outlines_steps.py:43

  Примеры:
    | имя              | email          | сообщение                              |
    | Виталий Игоревич | [email protected] | Есть интересный проект, нужно обсудить |
    | Марина Банраул   | [email protected] | Мне нравятся ваши дизайны, хочу сайт   |

1 feature (1 passed)
2 scenarios (2 passed)
12 steps (12 passed)
    """,
    )
예제 #16
0
def test_no_server():
    '"harvest" --no-server does not start the server'

    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=3 --apps=foobar --no-server" % (python_path,))

    assert_equals(status, 0, out)
    assert "Django's builtin server is running at" not in out
예제 #17
0
def test_no_server():
    '"harvest" --no-server does not start the server'

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

    assert_equals(status, 0, out)
    assert "Django's builtin server is running at" not in out
예제 #18
0
def test_no_server():
    '"harvest" --no-server does not start the server'

    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
예제 #19
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
예제 #20
0
def test_django_agains_alfaces():
    'running the "harvest" django command with verbosity 3'

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

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
예제 #21
0
def test_excluding_app():
    'running "harvest" with --avoid-apps=one_app'

    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
예제 #22
0
def test_excluding_apps_separated_by_comma():
    'running "harvest" with --avoid-apps=multiple,apps'

    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
예제 #23
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()
예제 #24
0
def test_limit_by_app_getting_all_apps_by_comma():
    'running "harvest" with --apps=multiple,apps,separated,by,comma'

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --no-color --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
예제 #25
0
def test_limit_by_app_getting_all_apps_by_comma():
    'running "harvest" with --apps=multiple,apps,separated,by,comma'

    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
예제 #26
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
예제 #27
0
def test_limit_by_app_getting_one_app():
    'running "harvest" with --apps=one_app'

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

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
예제 #28
0
def test_excluding_app():
    'running "harvest" with --avoid-apps=one_app'

    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=3 --avoid-apps=donothing" % (python_path,))
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
예제 #29
0
def test_django_against_alfaces():
    'running the "harvest" django command with verbosity 3'

    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=3" % (python_path,))
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
예제 #30
0
def test_excluding_app():
    'running "harvest" with --avoid-apps=one_app'

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --no-color --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
예제 #31
0
def test_limit_by_app_getting_one_app():
    'running "harvest" with --apps=one_app'

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

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
예제 #32
0
def test_limit_by_app_getting_one_app():
    'running "harvest" with --apps=one_app'

    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=3 --apps=foobar" % (python_path,))
    assert_equals(status, 0, out)

    assert "Test the django app DO NOTHING" not in out
    assert "Test the django app FOO BAR" in out
예제 #33
0
def test_excluding_apps_separated_by_comma():
    'running "harvest" with --avoid-apps=multiple,apps'

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --no-color --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
예제 #34
0
def test_django_agains_alfaces():
    'running the "harvest" django command with verbosity 3'

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

    assert "Test the django app DO NOTHING" in out
    assert "Test the django app FOO BAR" in out
예제 #35
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)
예제 #36
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'

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

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
예제 #37
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'

    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
예제 #38
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()
예제 #39
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()
예제 #40
0
def test_running_only_specified_features():
    'it can run only the specified features, passing the file path'

    status, out = subprocess.getstatusoutput(
        "%s manage.py harvest --verbosity=3 " \
        "foobar/features/foobar.feature" % (python_path,))

    assert_equals(status, 0, out)

    assert "Test the django app FOO BAR" in out
    assert "Test the django app DO NOTHING" not in out
예제 #41
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()
예제 #42
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()
예제 #43
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()
예제 #44
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'

    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
예제 #45
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()
예제 #46
0
def test_running_only_specified_features():
    'it can run only the specified features, passing the file path'

    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
예제 #47
0
def test_running_only_specified_features():
    'it can run only the specified features, passing the file path'

    status, out = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --no-color " \
        "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
예제 #48
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'

    status, out = commands.getstatusoutput(
        "python manage.py harvest --settings=avoidallappssettings "
        "--verbosity=3 --no-color --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
예제 #49
0
def test_running_all_apps_but_lettuce_avoid_apps():
    'running the "harvest" will run all apps but those within ' \
             'LETTUCE_AVOID_APPS'

    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
예제 #50
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()
예제 #51
0
def test_specifying_features_in_inner_directory():
    'it can run only the specified features from a subdirectory'

    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
예제 #52
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()
예제 #53
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
예제 #54
0
def test_django_specifying_scenarios_to_run():
    'django harvest can run only specified scenarios with ' \
            '--scenarios or -s options'

    status, out = subprocess.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
예제 #55
0
def test_django_specifying_scenarios_to_run_by_tag():
    'django harvest can run only specified scenarios with ' \
            '--tags or -t options'

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

    assert "3rd scenario" in out
    assert "6th scenario" in out

    assert "1st scenario" not in out
    assert "2rd scenario" not in out
    assert "4th scenario" not in out
    assert "5th scenario" not in out
예제 #56
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()
예제 #57
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()
예제 #58
0
def test_django_background_server_running_in_background():
    'the django builtin server fails if the HTTP port is not available'

    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(8000)
        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:8000"\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")
        assert_equals(out, e)
        assert_not_equals(status, 0)

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