コード例 #1
0
    def test_command_with_html_inside_text(self):
        test1 = MdTest("name", "fixture")
        command1 = CommandCode("text", "code")
        test1.add_command(command1)

        annotate_source_lineno([test1], """
        # [name](- "fixture")

        some text [*text*](- "code")
        """)

        assert test1.get_lineno() == 2
        assert command1.get_lineno() == 4
コード例 #2
0
    def test_single_command(self):
        test1 = MdTest("name", "fixture")
        command1 = CommandCode("text", "code")
        test1.add_command(command1)

        annotate_source_lineno([test1], """
        # [name](- "fixture")

        some text [text](- "code")
        """)

        assert test1.get_lineno() == 2
        assert command1.get_lineno() == 4
コード例 #3
0
def test_instrumeting_overview_link_with_inner_code():
    assert_commands_in_basic_tests(
        text='''
# [Basic](- "basic")
[```code```](- "sth(#TEXT)")
''',
        commands=[CommandCode("code", "sth(#TEXT)"),
                  CommandBlock("code")])
コード例 #4
0
def test_concordion_instrumeting_overview_reference_link_by_text():
    assert_commands_in_basic_tests(text='''
# [Basic](- "basic")
[value][]

[value]: - "command"
''',
                                   commands=[CommandCode("value", "command")])
コード例 #5
0
def test_should_escape_non_alfacharacters_names():
    expected_test = MdTest("Example_2", "basic_2")
    expected_test.add_command(CommandCode("Jane Smith", "#name"))

    assert_code_produces(text='''
# [Example 2](- "basic 2")
[Jane Smith](- "#name")).
''',
                         expected_tests=[expected_test])
コード例 #6
0
def test_concordion_example_should_continue_when_lower_level_header_starts():
    expected_test = MdTest("Blocks", "basic")
    expected_test.add_command(CommandCode("command", "#name"))

    assert_code_produces(text='''
### [Blocks](- "basic")

#### Blocks2
[command](- "#name")).
''',
                         expected_tests=[expected_test])
コード例 #7
0
def test_next_test_with_implementation_status_should_end_case():
    expected_test = MdTest("Blocks", "basic")
    expected_test.add_command(CommandCode("command", "#name"))

    assert_code_produces(text='''
# [Blocks](- "basic")
[command](- "#name")).

# [Blocks](- "basic c:status=ExpectedToFail")
[command2](- "#name")).
''',
                         expected_tests=[expected_test])
コード例 #8
0
    def parse_command(self, cmd):
        if isinstance(cmd, CommandBlock):
            self.code_block_count += 1
            return generate_set(
                CommandCode(cmd.get_block(),
                            'code' + str(self.code_block_count)))

        _substitute_TEXT_variable(cmd)

        for gen in get_generators_commands():
            if bool(re.search(gen['re'], cmd.get_code())):
                return (gen['generator'])(cmd)

        return generate_code_python_symantics(cmd.get_code())
コード例 #9
0
 def _parse_in_test_element(self, e, parent_element):
     if _is_concordion_link(e) and not _is_header(parent_element):
         code = _get_concordion_command(e)
         self._add_command_to_test(CommandCode(''.join(e.itertext()), code))
     if e.tag == 'code':
         self._add_command_to_test(CommandBlock(e.text))
コード例 #10
0
def test_instrumeting_overview_link_with_inner_formating_escapes_it():
    assert_commands_in_basic_tests(text='''
# [Basic](- "basic")
[*em*](- "sth(#TEXT)")
''',
                                   commands=[CommandCode("em", "sth(#TEXT)")])
コード例 #11
0
def test_concordion_instrumeting_overview():
    assert_commands_in_basic_tests(text='''
# [Basic](- "basic")
[value](- "command")
''',
                                   commands=[CommandCode("value", "command")])
コード例 #12
0
splittingNames_md_concordionExample = '''
# Splitting Names

To help personalise our mailshots we want to have the first name and last name of the customer.
Unfortunately the customer data that we are supplied only contains full names.

The system therefore attempts to break a supplied full name into its constituents by splitting around whitespace.

### [Example](- "basic")

The full name [Jane Smith](- "#name") is [broken](- "#result = split(#name)") into first name [Jane](- "?=#result.firstName") and last name [Smith](- "?=#result.lastName").
'''
expected_code_splittingNames_md_concordionExample = MdTest("Example", "basic")
expected_code_splittingNames_md_concordionExample.add_commands([
    CommandCode("Jane Smith", "#name"),
    CommandCode("broken", "#result = split(#name)"),
    CommandCode("Jane", "?=#result.firstName"),
    CommandCode("Smith", "?=#result.lastName"),
])


def assert_code_produces(text, expected_tests):
    tests = markdownparser.parseMarkdownForConcordionTests(text)
    assert tests == expected_tests


def assert_commands_in_basic_tests(text, commands):
    expected_test = MdTest("Basic", "basic")
    expected_test.add_commands(commands)