Ejemplo n.º 1
0
def test_scenario_may_own_outlines():
    "A scenario may own outlines"
    scenario = Scenario.from_string(OUTLINED_SCENARIO)

    assert_equals(len(scenario.steps), 4)
    expected_sentences = [
        'Given I have entered <input_1> into the calculator',
        'And I have entered <input_2> into the calculator',
        'When I press <button>',
        'Then the result should be <output> on the screen',
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.name, "Add two numbers")
    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '2', 'input_2': '5', 'button': 'add', 'output': '7'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
Ejemplo n.º 2
0
def test_scenario_has_repr():
    "Scenario implements __repr__ nicely"
    scenario = Scenario.from_string(SCENARIO1)
    assert_equals(
        repr(scenario),
        '<Scenario: "Adding some students to my university database">'
    )
Ejemplo n.º 3
0
def test_scenario_outline3_fr_from_string():
    'Language: FR -> Scenario.from_string, with scenario outline, third case'
    lang = Language('fr')
    scenario = Scenario.from_string(OUTLINED_SCENARIO2, language=lang)

    assert_equals(scenario.name, 'Ajouter 2 nombres')
    assert_equals(scenario.outlines, [
        {
            'input_1': '20',
            'input_2': '30',
            'bouton': 'add',
            'output': '50'
        },
        {
            'input_1': '2',
            'input_2': '5',
            'bouton': 'add',
            'output': '7'
        },
        {
            'input_1': '0',
            'input_2': '40',
            'bouton': 'add',
            'output': '40'
        },
    ])
Ejemplo n.º 4
0
def test_scenario_has_steps():
    "A scenario object should have a list of steps"

    scenario = Scenario.from_string(SCENARIO1)

    assert_equals(type(scenario.steps), list)
    assert_equals(len(scenario.steps), 4, "It should have 4 steps")

    expected_sentences = [
        "Given I have the following courses in my university:",
        "When I consolidate the database into 'courses.txt'",
        "Then I see the 1st line of 'courses.txt' has 'Computer Science:5'",
        "And I see the 2nd line of 'courses.txt' has 'Nutrition:4'",
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.steps[0].keys, ('Name', 'Duration'))
    assert_equals(
        scenario.steps[0].hashes,
        [
            {'Name': 'Computer Science', 'Duration': '5 years'},
            {'Name': 'Nutrition', 'Duration': '4 years'},
        ]
    )
Ejemplo n.º 5
0
def test_scenario_tables_are_solved_against_outlines():
    "Outline substitution should apply to tables within a scenario"
    expected_hashes_per_step = [
        # a = 1, b = 2
        [{
            'Parameter': 'a',
            'Value': '1'
        }, {
            'Parameter': 'b',
            'Value': '2'
        }],  # Given ...
        [],  # When I run the program
        [],  # Then I crash hard-core

        # a = 2, b = 4
        [{
            'Parameter': 'a',
            'Value': '2'
        }, {
            'Parameter': 'b',
            'Value': '4'
        }],
        [],
        []
    ]

    scenario = Scenario.from_string(
        OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_TABLE)
    for step, expected_hashes in zip(scenario.solved_steps,
                                     expected_hashes_per_step):
        assert_equals(type(step), Step)
        assert_equals(step.hashes, expected_hashes)
Ejemplo n.º 6
0
def test_scenario_has_repr():
    "Scenario implements __repr__ nicely"
    scenario = Scenario.from_string(SCENARIO1)
    assert_equals(
        repr(scenario),
        '<Scenario: "Adding some students to my university database">'
    )
Ejemplo n.º 7
0
def test_scenario_may_own_outlines():
    "A scenario may own outlines"
    scenario = Scenario.from_string(OUTLINED_SCENARIO)

    assert_equals(len(scenario.steps), 4)
    expected_sentences = [
        'Given I have entered <input_1> into the calculator',
        'And I have entered <input_2> into the calculator',
        'When I press <button>',
        'Then the result should be <output> on the screen',
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.name, "Add two numbers")
    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '2', 'input_2': '5', 'button': 'add', 'output': '7'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
Ejemplo n.º 8
0
def test_scenario_has_steps():
    "A scenario object should have a list of steps"

    scenario = Scenario.from_string(SCENARIO1)

    assert_equals(type(scenario.steps), list)
    assert_equals(len(scenario.steps), 4, "It should have 4 steps")

    expected_sentences = [
        "Given I have the following courses in my university:",
        "When I consolidate the database into 'courses.txt'",
        "Then I see the 1st line of 'courses.txt' has 'Computer Science:5'",
        "And I see the 2nd line of 'courses.txt' has 'Nutrition:4'",
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.steps[0].keys, ('Name', 'Duration'))
    assert_equals(scenario.steps[0].hashes, [
        {
            'Name': 'Computer Science',
            'Duration': '5 years'
        },
        {
            'Name': 'Nutrition',
            'Duration': '4 years'
        },
    ])
Ejemplo n.º 9
0
def test_scenario_matches_tags_excluding_when_scenario_has_no_tags():
    ("When Scenario#matches_tags is called for a scenario "
     "that has no tags and the given match is a exclusionary tag")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=(SCENARIO1.strip()))

    assert scenario.matches_tags(['-nope', '-neither'])
Ejemplo n.º 10
0
def test_scenario_has_tag():
    "A scenario object should be able to find at least one tag " \
       "on the first line"

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag'])
Ejemplo n.º 11
0
def test_scenario_has_tag():
    "A scenario object should be able to find at least one tag " \
       "on the first line"

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=('@onetag\n' +
                                                     SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag'])
Ejemplo n.º 12
0
def test_scenario_has_tag():
    ("A scenario object should be able to find at least one tag "
     "on the first line")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=('@onetag\n' +
                                                     SCENARIO1.strip()))

    expect(scenario.tags).to.equal(['onetag'])
Ejemplo n.º 13
0
def test_scenario_matches_tags_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with ~ "
     "it will consider a fuzzywuzzy match")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@anothertag\n@another-tag\n' + SCENARIO1.strip()))

    assert scenario.matches_tags(['~another'])
Ejemplo n.º 14
0
def test_scenario_has_tag():
    ("A scenario object should be able to find at least one tag "
     "on the first line")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n' + SCENARIO1.strip()))

    expect(scenario.tags).to.equal(['onetag'])
Ejemplo n.º 15
0
def test_scenario_matches_tags_excluding_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with -~ "
     "it will exclude that tag from that fuzzywuzzy match")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@anothertag\n@another-tag\n' + SCENARIO1.strip()))

    assert not scenario.matches_tags(['-~anothertag'])
Ejemplo n.º 16
0
def test_scenario_matches_tags_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with ~ "
     "it will consider a fuzzywuzzy match")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=SCENARIO1.strip(),
                                    tags=['anothertag', 'another-tag'])

    assert scenario.matches_tags(['~another'])
Ejemplo n.º 17
0
def test_scenario_with_inline_comments():
    ("Scenarios can have steps with inline comments")

    scenario = Scenario.from_string(INLINE_COMMENTS)

    step1, step2 = scenario.steps

    expect(step1.sentence).to.equal(u'Given I am using an anvil')
    expect(step2.sentence).to.equal(u'And I am using a hammer')
Ejemplo n.º 18
0
def test_scenario_tables_are_solved_against_outlines():
    "Outline substitution should apply to multiline strings within a scenario"
    expected_multiline = '<div>outline value</div>'

    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_MULTILINE)
    step = scenario.solved_steps[0]
    
    assert_equals(type(step), Step)
    assert_equals(step.multiline, expected_multiline)
Ejemplo n.º 19
0
def test_scenario_matches_tags_excluding_when_scenario_has_no_tags():
    ("When Scenario#matches_tags is called for a scenario "
     "that has no tags and the given match is a exclusionary tag")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=(SCENARIO1.strip()))

    assert scenario.matches_tags(['-nope', '-neither'])
Ejemplo n.º 20
0
def test_scenario_matches_tags_excluding_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with -~ "
     "it will exclude that tag from that fuzzywuzzy match")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@anothertag\n@another-tag\n' + SCENARIO1.strip()))

    assert not scenario.matches_tags(['-~anothertag'])
Ejemplo n.º 21
0
def test_scenario_with_inline_comments():
    ("Scenarios can have steps with inline comments")

    scenario = Scenario.from_string(INLINE_COMMENTS)

    step1, step2 = scenario.steps

    expect(step1.sentence).to.equal(u'Given I am using an anvil')
    expect(step2.sentence).to.equal(u'And I am using a hammer')
Ejemplo n.º 22
0
def test_scenario_has_name():
    "It should extract the name of the scenario"

    scenario = Scenario.from_string(SCENARIO1)

    assert isinstance(scenario, Scenario)

    assert_equals(scenario.name,
                  "Adding some students to my university database")
Ejemplo n.º 23
0
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=SCENARIO1.strip(),
                                    tags=['slow', 'firefox', 'chrome'])

    expect(scenario.represented()).to.equal(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
Ejemplo n.º 24
0
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@slow\n@firefox\n@chrome\n' + SCENARIO1.strip()))

    assert that(scenario.represented()).equals(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
Ejemplo n.º 25
0
def test_scenario_matches_tags_excluding():
    ("When Scenario#matches_tags is called with a member starting with - "
     "it will exclude that tag from the matching")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=SCENARIO1.strip(),
                                    tags=['anothertag', 'another-tag'])

    assert not scenario.matches_tags(['-anothertag'])
    assert scenario.matches_tags(['-foobar'])
Ejemplo n.º 26
0
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@slow\n@firefox\n@chrome\n' + SCENARIO1.strip()))

    assert that(scenario.represented()).equals(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
Ejemplo n.º 27
0
def test_scenario_ignore_commented_lines_from_examples():
    "Comments on scenario example should be ignored"
    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_COMMENTS_ON_EXAMPLES)

    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
Ejemplo n.º 28
0
def test_scenario_with_hash_within_single_quotes():
    ("Scenarios have hashes within single quotes and yet don't "
     "consider them as comments")

    scenario = Scenario.from_string(
        INLINE_COMMENTS_IGNORED_WITHIN_SINGLE_QUOTES)

    step1, step2 = scenario.steps

    expect(step1.sentence).to.equal(u'Given I am logged in on twitter')
    expect(step2.sentence).to.equal(u"When I search for the hashtag '#hammer'")
Ejemplo n.º 29
0
def test_scenario_matches_tags_excluding():
    ("When Scenario#matches_tags is called with a member starting with - "
     "it will exclude that tag from the matching")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=SCENARIO1.strip(),
        tags=['anothertag', 'another-tag'])

    assert not scenario.matches_tags(['-anothertag'])
    assert scenario.matches_tags(['-foobar'])
Ejemplo n.º 30
0
def test_scenario_matches_tags():
    ("A scenario with tags should respond with True when "
     ".matches_tags() is called with a valid list of tags")

    scenario = Scenario.from_string(SCENARIO1,
                                    original_string=SCENARIO1.strip(),
                                    tags=['onetag', 'another-one'])

    expect(scenario.tags).to.equal(['onetag', 'another-one'])
    assert scenario.matches_tags(['onetag'])
    assert scenario.matches_tags(['another-one'])
Ejemplo n.º 31
0
def test_scenario_matches_tags():
    ("A scenario with tags should respond with True when "
     ".matches_tags() is called with a valid list of tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n@another-one\n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag', 'another-one'])
    assert scenario.matches_tags(['onetag'])
    assert scenario.matches_tags(['another-one'])
Ejemplo n.º 32
0
def test_scenario_matches_tags():
    ("A scenario with tags should respond with True when "
     ".matches_tags() is called with a valid list of tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n@another-one\n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag','another-one'])
    assert scenario.matches_tags(['onetag'])
    assert scenario.matches_tags(['another-one'])
Ejemplo n.º 33
0
def test_scenario_has_name():
    "It should extract the name of the scenario"

    scenario = Scenario.from_string(SCENARIO1)

    assert isinstance(scenario, Scenario)

    assert_equals(
        scenario.name,
        "Adding some students to my university database"
    )
Ejemplo n.º 34
0
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=SCENARIO1.strip(),
        tags=['slow', 'firefox', 'chrome'])

    expect(scenario.represented()).to.equal(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
Ejemplo n.º 35
0
def test_scenario_with_hash_within_single_quotes():
    ("Scenarios have hashes within single quotes and yet don't "
     "consider them as comments")

    scenario = Scenario.from_string(
        INLINE_COMMENTS_IGNORED_WITHIN_SINGLE_QUOTES)

    step1, step2 = scenario.steps

    expect(step1.sentence).to.equal(u'Given I am logged in on twitter')
    expect(step2.sentence).to.equal(u"When I search for the hashtag '#hammer'")
Ejemplo n.º 36
0
def test_scenario_ignore_commented_lines_from_examples():
    "Comments on scenario example should be ignored"
    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_COMMENTS_ON_EXAMPLES)

    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
Ejemplo n.º 37
0
def test_scenario_matches_tags():
    ("A scenario with tags should respond with True when "
     ".matches_tags() is called with a valid list of tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=SCENARIO1.strip(),
        tags=['onetag', 'another-one'])

    expect(scenario.tags).to.equal(['onetag', 'another-one'])
    assert scenario.matches_tags(['onetag'])
    assert scenario.matches_tags(['another-one'])
Ejemplo n.º 38
0
def test_scenario_has_tags_singleline():
    ("A scenario object should be able to find many tags " "on the first line")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag @another @$%^&even-weird_chars \n' +
                         SCENARIO1.strip()))

    expect(scenario.tags).to.equal([
        'onetag',
        'another',
        '$%^&even-weird_chars',
    ])
Ejemplo n.º 39
0
def test_scenario_aggregate_all_examples_blocks():
    "All scenario's examples block should be translated to outlines"
    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_MORE_THAN_ONE_EXAMPLES_BLOCK)

    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '2', 'input_2': '5', 'button': 'add', 'output': '7'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
            {'input_1': '20', 'input_2': '33', 'button': 'add', 'output': '53'},
            {'input_1': '12', 'input_2': '40', 'button': 'add', 'output': '52'},
        ]
    )
Ejemplo n.º 40
0
def test_scenario_has_tags_singleline():
    "A scenario object should be able to find many tags " \
       "on the first line"

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=(
            '@onetag @another @$%^&even-weird_chars \n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals([
        'onetag',
        'another',
        '$%^&even-weird_chars',
    ])
Ejemplo n.º 41
0
def test_scenario_has_tags_singleline():
    ("A scenario object should be able to find many tags "
     "on the first line")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=(
            '@onetag @another @$%^&even-weird_chars \n' + SCENARIO1.strip()))

    expect(scenario.tags).to.equal([
        'onetag',
        'another',
        '$%^&even-weird_chars',
    ])
Ejemplo n.º 42
0
def test_scenario_has_tags_singleline():
    "A scenario object should be able to find many tags " \
       "on the first line"

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag @another @$%^&even-weird_chars \n' +
                         SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals([
        'onetag',
        'another',
        '$%^&even-weird_chars',
    ])
Ejemplo n.º 43
0
def test_scenario_aggregate_all_examples_blocks():
    "All scenario's examples block should be translated to outlines"
    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_MORE_THAN_ONE_EXAMPLES_BLOCK)

    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '2', 'input_2': '5', 'button': 'add', 'output': '7'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
            {'input_1': '20', 'input_2': '33', 'button': 'add', 'output': '53'},
            {'input_1': '12', 'input_2': '40', 'button': 'add', 'output': '52'},
        ]
    )
Ejemplo n.º 44
0
def test_scenario_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO, language=ptbr)

    assert_equals(
        scenario.name,
        u'Consolidar o banco de dados de cursos universitários em arquivo texto'
    )
    assert_equals(
        scenario.steps[0].hashes,
        [
            {'Nome': u'Ciência da Computação', u'Duração': '5 anos'},
            {'Nome': u'Nutrição', u'Duração': '4 anos'},
        ]
    )
Ejemplo n.º 45
0
def test_scenario_outline1_ru_from_string():
    'Language: RU -> Scenario.from_string, with scenario outline, first case'
    ru = Language('ru')
    scenario = Scenario.from_string(SCENARIO_OUTLINE1, language=ru)

    assert_equals(
        scenario.name,
        u'Заполнение пользователей в базу'
    )
    assert_equals(
        scenario.outlines,
        [
            {u'имя': u'Вася', u'возраст': '22'},
            {u'имя': u'Петя', u'возраст': '30'},
        ]
    )
Ejemplo n.º 46
0
def test_scenario_outline2_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string, with scenario outline, second case'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO_OUTLINE2, language=ptbr)

    assert_equals(scenario.name, 'Cadastrar um aluno no banco de dados')
    assert_equals(scenario.outlines, [
        {
            'nome': u'Gabriel',
            u'idade': '99'
        },
        {
            'nome': u'João',
            u'idade': '100'
        },
    ])
Ejemplo n.º 47
0
def test_scenario_outline1_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string, with scenario outline, first case'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO_OUTLINE1, language=ptbr)

    assert_equals(scenario.name, 'Cadastrar um aluno no banco de dados')
    assert_equals(scenario.outlines, [
        {
            'nome': 'Gabriel',
            'idade': '22'
        },
        {
            'nome': 'João',
            'idade': '30'
        },
    ])
Ejemplo n.º 48
0
def test_scenario_outline1_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string, with scenario outline, first case'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO_OUTLINE1, language=ptbr)

    assert_equals(
        scenario.name,
        'Cadastrar um aluno no banco de dados'
    )
    assert_equals(
        scenario.outlines,
        [
            {'nome': 'Gabriel', 'idade': '22'},
            {'nome': 'João', 'idade': '30'},
        ]
    )
Ejemplo n.º 49
0
def test_scenario_ru_from_string():
    'Language: RU -> Scenario.from_string'
    ru = Language('ru')
    scenario = Scenario.from_string(SCENARIO, language=ru)

    assert_equals(
        scenario.name,
        u'Сохранение базы курсов универитета в текстовый файл'
    )
    assert_equals(
        scenario.steps[0].hashes,
        [
            {u'Название': u'Матан', u'Длительность': u'2 года'},
            {u'Название': u'Основы программирования', u'Длительность': u'1 год'},
        ]
    )
Ejemplo n.º 50
0
def test_scenario_outline1_ru_from_string():
    'Language: RU -> Scenario.from_string, with scenario outline, first case'
    ru = Language('ru')
    scenario = Scenario.from_string(SCENARIO_OUTLINE1, language=ru)

    assert_equals(scenario.name, 'Заполнение пользователей в базу')
    assert_equals(scenario.outlines, [
        {
            'имя': 'Вася',
            'возраст': '22'
        },
        {
            'имя': 'Петя',
            'возраст': '30'
        },
    ])
Ejemplo n.º 51
0
def test_scenario_fr_from_string():
    'Language: FR -> Scenario.from_string'
    lang = Language('fr')
    scenario = Scenario.from_string(SCENARIO, language=lang)

    assert_equals(
        scenario.name,
        u'Ajout de plusieurs cursus dans la base de mon université'
    )
    assert_equals(
        scenario.steps[0].hashes,
        [
            {'Nom': u"Science de l'Informatique", u'Durée': '5 ans'},
            {'Nom': u'Nutrition', u'Durée': '4 ans'},
        ]
    )
Ejemplo n.º 52
0
def test_scenario_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO, language=ptbr)

    assert_equals(
        scenario.name,
        u'Consolidar o banco de dados de cursos universitários em arquivo texto'
    )
    assert_equals(
        scenario.steps[0].hashes,
        [
            {'Nome': u'Ciência da Computação', u'Duração': '5 anos'},
            {'Nome': u'Nutrição', u'Duração': '4 anos'},
        ]
    )
Ejemplo n.º 53
0
def test_scenario_outline2_ptbr_from_string():
    'Language: PT-BR -> Scenario.from_string, with scenario outline, second case'
    ptbr = Language('pt-br')
    scenario = Scenario.from_string(SCENARIO_OUTLINE2, language=ptbr)

    assert_equals(
        scenario.name,
        'Cadastrar um aluno no banco de dados'
    )
    assert_equals(
        scenario.outlines,
        [
            {'nome': u'Gabriel', u'idade': '99'},
            {'nome': u'João', u'idade': '100'},
        ]
    )
Ejemplo n.º 54
0
def test_scenario_outline3_fr_from_string():
    'Language: FR -> Scenario.from_string, with scenario outline, third case'
    lang = Language('fr')
    scenario = Scenario.from_string(OUTLINED_SCENARIO2, language=lang)

    assert_equals(
        scenario.name,
        'Ajouter 2 nombres'
    )
    assert_equals(
        scenario.outlines,
        [
            {u'input_1':u'20',u'input_2':u'30',u'bouton':u'add',u'output':u'50'},
            {u'input_1':u'2',u'input_2':u'5',u'bouton':u'add',u'output':u'7'},
            {u'input_1':u'0',u'input_2':u'40',u'bouton':u'add',u'output':u'40'},
        ]
    )
Ejemplo n.º 55
0
def test_scenario_outline1_fr_from_string():
    'Language: FR -> Scenario.from_string, with scenario outline, first case'
    lang = Language('fr')
    scenario = Scenario.from_string(OUTLINED_SCENARIO, language=lang)

    assert_equals(
        scenario.name,
        'Ajouter 2 nombres'
    )
    assert_equals(
        scenario.outlines,
        [
            {u'input_1':u'20',u'input_2':u'30',u'bouton':u'add',u'output':u'50'},
            {u'input_1':u'2',u'input_2':u'5',u'bouton':u'add',u'output':u'7'},
            {u'input_1':u'0',u'input_2':u'40',u'bouton':u'add',u'output':u'40'},
        ]
    )
Ejemplo n.º 56
0
def test_scenario_ru_from_string():
    'Language: RU -> Scenario.from_string'
    ru = Language('ru')
    scenario = Scenario.from_string(SCENARIO, language=ru)

    assert_equals(scenario.name,
                  'Сохранение базы курсов универитета в текстовый файл')
    assert_equals(scenario.steps[0].hashes, [
        {
            'Название': 'Матан',
            'Длительность': '2 года'
        },
        {
            'Название': 'Основы программирования',
            'Длительность': '1 год'
        },
    ])
Ejemplo n.º 57
0
def test_scenario_outline1_fr_from_string():
    'Language: FR -> Scenario.from_string, with scenario outline, first case'
    lang = Language('fr')
    scenario = Scenario.from_string(OUTLINED_SCENARIO, language=lang)

    assert_equals(
        scenario.name,
        'Ajouter 2 nombres'
    )
    assert_equals(
        scenario.outlines,
        [
            {'input_1':'20','input_2':'30','bouton':'add','output':'50'},
            {'input_1':'2','input_2':'5','bouton':'add','output':'7'},
            {'input_1':'0','input_2':'40','bouton':'add','output':'40'},
        ]
    )
Ejemplo n.º 58
0
def test_scenario_tables_are_solved_against_outlines():
    "Outline substitution should apply to tables within a scenario"
    expected_hashes_per_step = [
            # a = 1, b = 2
            [{'Parameter': 'a', 'Value': '1'}, {'Parameter': 'b', 'Value': '2'}], # Given ...
            [], # When I run the program
            [], # Then I crash hard-core

            # a = 2, b = 4
            [{'Parameter': 'a', 'Value': '2'}, {'Parameter': 'b', 'Value': '4'}],
            [],
            []
        ]

    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_TABLE)
    for step, expected_hashes in zip(scenario.solved_steps, expected_hashes_per_step):
        assert_equals(type(step), Step)
        assert_equals(step.hashes, expected_hashes)