def test_find_names_and_device(self):
        matches = parse_ljsl.find_names(TEST_CORPUS_WITH_DEVICE)
        self.corpus_matches_tests(matches)
        self.assertEqual(len(matches), 2)
        self.assertEqual(len(matches[0][0].device_types), 1)
        self.assertEqual(    matches[0][0].device_types[0], 'T4')

        self.assertEqual(len(matches[1][0].device_types), 2)
        self.assertEqual(    matches[1][0].device_types[0], 'T4')
        self.assertEqual(    matches[1][0].device_types[1], 'T7')

        self.assertEqual(len(matches[1][1].device_types), 2)
        self.assertEqual(    matches[1][1].device_types[0], 'T4')
        self.assertEqual(    matches[1][1].device_types[1], 'T7')

        self.assertEqual(len(matches[1][2].device_types), 2)
        self.assertEqual(    matches[1][2].device_types[0], 'T4')
        self.assertEqual(    matches[1][2].device_types[1], 'T7')

        self.assertEqual(len(matches[1][3].device_types), 2)
        self.assertEqual(    matches[1][3].device_types[0], 'T4')
        self.assertEqual(    matches[1][3].device_types[1], 'T7')

        self.assertEqual(len(matches[1][4].device_types), 2)
        self.assertEqual(    matches[1][4].device_types[0], 'T4')
        self.assertEqual(    matches[1][4].device_types[1], 'T7')
Exemple #2
0
    def test_find_names_and_device(self):
        matches = parse_ljsl.find_names(TEST_CORPUS_WITH_DEVICE)
        self.corpus_matches_tests(matches)
        self.assertEqual(len(matches), 2)
        self.assertEqual(len(matches[0][0].device_types), 1)
        self.assertEqual(matches[0][0].device_types[0], 'T4')

        self.assertEqual(len(matches[1][0].device_types), 2)
        self.assertEqual(matches[1][0].device_types[0], 'T4')
        self.assertEqual(matches[1][0].device_types[1], 'T7')

        self.assertEqual(len(matches[1][1].device_types), 2)
        self.assertEqual(matches[1][1].device_types[0], 'T4')
        self.assertEqual(matches[1][1].device_types[1], 'T7')

        self.assertEqual(len(matches[1][2].device_types), 2)
        self.assertEqual(matches[1][2].device_types[0], 'T4')
        self.assertEqual(matches[1][2].device_types[1], 'T7')

        self.assertEqual(len(matches[1][3].device_types), 2)
        self.assertEqual(matches[1][3].device_types[0], 'T4')
        self.assertEqual(matches[1][3].device_types[1], 'T7')

        self.assertEqual(len(matches[1][4].device_types), 2)
        self.assertEqual(matches[1][4].device_types[0], 'T4')
        self.assertEqual(matches[1][4].device_types[1], 'T7')
def inject_data_service():
    target_code = flask.request.args.get("input", "")
    names = parse_ljsl.find_names(target_code)

    reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True)

    not_found_reg_names = []
    tag_class_tuples = lj_scribe.find_classes_from_map(names, reg_maps, not_found_reg_names)

    tag_subtags_by_class = lj_scribe.fia_organize_tag_by_class(tag_class_tuples)

    target_code = lj_scribe.fix_not_found_reg_names(target_code, not_found_reg_names)

    original_names = map(lj_scribe.find_original_tag_str, names)

    summaries = map(lambda x: lj_scribe.render_tag_summary(*x), zip(tag_subtags_by_class, names, original_names))

    original_names_to_summaries = zip(original_names, summaries)

    for (original_name, summary) in original_names_to_summaries:
        target_code = target_code.replace(original_name, summary)

    prefix = flask.render_template("scribe_prefix.html")
    postfix = flask.render_template("scribe_postfix.html")
    return prefix + target_code + postfix
Exemple #4
0
    def test_missing_optional_param_value(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:INVALID#(0:1:)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
def render_scribe(target_code):
    names = parse_ljsl.find_names(target_code)

    not_found_reg_names = []
    tag_class_tuples = lj_scribe.find_classes_from_map(
        names,
        reg_maps,
        not_found_reg_names
    )

    tag_subtags_by_class = lj_scribe.fia_organize_tag_by_class(tag_class_tuples)

    target_code = lj_scribe.fix_not_found_reg_names(
        target_code,
        not_found_reg_names
    )

    original_names = map(lj_scribe.find_original_tag_str, names)

    summaries = map(
        lambda x: lj_scribe.render_tag_summary(*x),
        zip(tag_subtags_by_class, names, original_names)
    )

    original_names_to_summaries = zip(original_names, summaries)

    for (original_name, summary) in original_names_to_summaries:
        target_code = target_code.replace(original_name, summary)

    prefix = flask.render_template("scribe_prefix.html")
    postfix = flask.render_template("scribe_postfix.html")
    return prefix + target_code + postfix
Exemple #6
0
    def test_missing_optional_param_value(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:INVALID#(0:1:)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
Exemple #7
0
    def test_ljmmm_and_no_ljmmm_mix(self):
        matches = parse_ljsl.find_names(
            "@registers:TEST,REST#(0:1),BES0T @registers:FEST#(0:1)"
        )

        self.assertEqual(len(matches), 2)

        target_match = matches[0]
        self.assertEqual(len(target_match), 3)
        
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        self.assertEqual(target_match[2].prefix, "BES0T")
        self.assertEqual(target_match[2].start_num, None)
        self.assertEqual(target_match[2].num_regs, None)
        self.assertEqual(target_match[2].num_between_regs, None)
        self.assertEqual(target_match[2].postfix, None)
        self.assertEqual(target_match[2].includes_ljmmm, False)

        target_match = matches[1]
        self.assertEqual(len(target_match), 1)
Exemple #8
0
    def test_ljmmm_and_no_ljmmm_mix(self):
        matches = parse_ljsl.find_names(
            "@registers:TEST,REST#(0:1),BES0T @registers:FEST#(0:1)")

        self.assertEqual(len(matches), 2)

        target_match = matches[0]
        self.assertEqual(len(target_match), 3)

        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        self.assertEqual(target_match[2].prefix, "BES0T")
        self.assertEqual(target_match[2].start_num, None)
        self.assertEqual(target_match[2].num_regs, None)
        self.assertEqual(target_match[2].num_between_regs, None)
        self.assertEqual(target_match[2].postfix, None)
        self.assertEqual(target_match[2].includes_ljmmm, False)

        target_match = matches[1]
        self.assertEqual(len(target_match), 1)
Exemple #9
0
    def test_wrong_prefix(self):
        test_corpus = TEST_CORPUS_INVALID % "@results:INVALID#(0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
Exemple #10
0
    def test_missing_front_paren(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:INVALID#0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
Exemple #11
0
def render_scribe(target_code, expand=False):
    names = parse_ljsl.find_names(target_code)

    not_found_reg_names = []
    tag_class_tuples = lj_scribe.find_classes_from_map(
        names,
        reg_maps,
        not_found_reg_names
    )

    tag_subtags_by_class = lj_scribe.fia_organize_tag_by_class(tag_class_tuples)

    target_code = lj_scribe.fix_not_found_reg_names(
        target_code,
        not_found_reg_names,

    )

    original_names = map(lj_scribe.find_original_tag_str, names)

    summaries = map(
        lambda x: lj_scribe.render_tag_summary(*x ,expand=expand),
        zip(tag_subtags_by_class, names, original_names)
    )

    original_names_to_summaries = zip(original_names, summaries)

    for (original_name, summary) in original_names_to_summaries:
        target_code = target_code.replace(original_name, summary)

    prefix = flask.render_template("scribe_prefix.html")
    postfix = flask.render_template("scribe_postfix.html")
    return prefix + target_code + postfix
Exemple #12
0
    def test_wrong_prefix(self):
        test_corpus = TEST_CORPUS_INVALID % "@results:INVALID#(0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
Exemple #13
0
    def test_missing_front_paren(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:INVALID#0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
Exemple #14
0
    def test_find_name_after_invalid(self):
        matches = parse_ljsl.find_names(TEST_CORPUS_MANY_WITH_INVALID)

        self.assertEqual(len(matches), 2)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "TEST")

        self.assertEqual(len(matches), 2)
        target_match = matches[1][0]
        self.assertEqual(target_match.prefix, "OTHERTEST")
Exemple #15
0
    def test_find_names(self):
        matches = parse_ljsl.find_names(TEST_CORPUS)

        self.assertEqual(len(matches), 2)

        lengths = map(lambda x: len(x), matches)
        self.assertEqual([1, 5], lengths)

        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "TEST")
        self.assertEqual(target_match.start_num, 120)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][0]
        self.assertEqual(target_match.prefix, "OTHERTEST")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 3)
        self.assertEqual(target_match.num_between_regs, None)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][1]
        self.assertEqual(target_match.prefix, "TEST")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][2]
        self.assertEqual(target_match.prefix, "OTHERTEST")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 3)
        self.assertEqual(target_match.num_between_regs, None)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][3]
        self.assertEqual(target_match.prefix, "lowertest")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 3)
        self.assertEqual(target_match.num_between_regs, None)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][4]
        self.assertEqual(target_match.prefix, "l")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 3)
        self.assertEqual(target_match.num_between_regs, None)
        self.assertEqual(target_match.postfix, "p")
        self.assertEqual(target_match.includes_ljmmm, True)
Exemple #16
0
    def test_find_name_after_invalid(self):
        matches = parse_ljsl.find_names(
            TEST_CORPUS_MANY_WITH_INVALID)

        self.assertEqual(len(matches), 2)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "TEST")

        self.assertEqual(len(matches), 2)
        target_match = matches[1][0]
        self.assertEqual(target_match.prefix, "OTHERTEST")
    def test_empty_device_type(self):
        matches = parse_ljsl.find_names(TEST_EMPTY_DEVICE)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "TEST")
        self.assertEqual(target_match.start_num, 120)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)
        self.assertEqual(len(matches[0][0].device_types), 0)
Exemple #18
0
    def test_empty_device_type(self):
        matches = parse_ljsl.find_names(TEST_EMPTY_DEVICE)

        self.assertEqual(len(matches), 1)
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "TEST")
        self.assertEqual(target_match.start_num, 120)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)
        self.assertEqual(len(matches[0][0].device_types), 0)
Exemple #19
0
    def test_find_no_ljmmm_tag(self):
        matches = parse_ljsl.find_names("@registers:TEST")

        self.assertEqual(len(matches), 1)

        target_match = matches[0]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)
Exemple #20
0
    def test_missing_pound(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:NOPOUND(0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 2)
        
        target_match = matches[0]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "NOPOUND")

        target_match = matches[1]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "VALID")
Exemple #21
0
    def test_missing_pound(self):
        test_corpus = TEST_CORPUS_INVALID % "@registers:NOPOUND(0:1)"
        matches = parse_ljsl.find_names(test_corpus)

        self.assertEqual(len(matches), 2)

        target_match = matches[0]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "NOPOUND")

        target_match = matches[1]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "VALID")
Exemple #22
0
    def test_find_no_ljmmm_tag(self):
        matches = parse_ljsl.find_names("@registers:TEST")

        self.assertEqual(len(matches), 1)

        target_match = matches[0]
        self.assertEqual(len(target_match), 1)
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)
def inject_data():
    """Controls to Inject data about register records into an HTML template.

    @return: HTML form through which the HTML template can be filled and
        rendered.
    @rtype: str or flask response (redirect)
    """
    if flask.request.method == "GET":
        return flask.render_template("inject_data.html")

    target_code = flask.request.form.get("input", "")
    names = parse_ljsl.find_names(target_code)

    reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True)
    dev_regs = reg_maps[lj_scribe.TARGET_DEVICE]

    tag_class_tuples = 0
    tag_subtags_by_class = 0

    # This is NOT the best way to fix this issue.
    # The code should use lj_scribe.TARGET_DEVICES!!!

    try:
        tag_class_tuples = lj_scribe.find_classes(names, dev_regs)
    except lj_scribe.RegisterNotFoundError as e:
        dev_regs = reg_maps[lj_scribe.TARGET_DEVICE_DIGIT]
        try:
            tag_class_tuples = lj_scribe.find_classes(names, dev_regs)

            tag_subtags_by_class = lj_scribe.organize_tag_by_class(tag_class_tuples, dev_regs)
        except lj_scribe.RegisterNotFoundError as e:
            return "Register %s not found in Modbus map." % e.missing_reg_name

    tag_subtags_by_class = lj_scribe.organize_tag_by_class(tag_class_tuples, dev_regs)

    original_names = map(lj_scribe.find_original_tag_str, names)

    summaries = map(lambda x: lj_scribe.render_tag_summary(*x), zip(tag_subtags_by_class, names, original_names))

    original_names_to_summaries = zip(original_names, summaries)

    for (original_name, summary) in original_names_to_summaries:
        target_code = target_code.replace(original_name, summary)

    prefix = flask.render_template("scribe_prefix.html")
    postfix = flask.render_template("scribe_postfix.html")
    return prefix + target_code + postfix
Exemple #24
0
    def test_postfix_values(self):
        matches = parse_ljsl.find_names(POSTFIX_CORPUS)

        self.assertEqual(len(matches), 2)
        self.assertEqual(len(matches[0]), 3)
        self.assertEqual(len(matches[1]), 1)

        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 2)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "AFTERWARDS")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[0][1]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 4)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 6)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[0][2]
        self.assertEqual(target_match.prefix, "VALIDAGAIN")
        self.assertEqual(target_match.start_num, 101)
        self.assertEqual(target_match.num_regs, 2)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "AFTERWARDS")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][0]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 100)
        self.assertEqual(target_match.num_regs, 200)
        self.assertEqual(target_match.num_between_regs, 300)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)
Exemple #25
0
    def test_postfix_values(self):
        matches = parse_ljsl.find_names(POSTFIX_CORPUS)

        self.assertEqual(len(matches), 2)
        self.assertEqual(len(matches[0]), 3)
        self.assertEqual(len(matches[1]), 1)
        
        target_match = matches[0][0]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 1)
        self.assertEqual(target_match.num_regs, 2)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "AFTERWARDS")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[0][1]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 4)
        self.assertEqual(target_match.num_regs, 5)
        self.assertEqual(target_match.num_between_regs, 6)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[0][2]
        self.assertEqual(target_match.prefix, "VALIDAGAIN")
        self.assertEqual(target_match.start_num, 101)
        self.assertEqual(target_match.num_regs, 2)
        self.assertEqual(target_match.num_between_regs, 3)
        self.assertEqual(target_match.postfix, "AFTERWARDS")
        self.assertEqual(target_match.includes_ljmmm, True)

        target_match = matches[1][0]
        self.assertEqual(target_match.prefix, "VALID")
        self.assertEqual(target_match.start_num, 100)
        self.assertEqual(target_match.num_regs, 200)
        self.assertEqual(target_match.num_between_regs, 300)
        self.assertEqual(target_match.postfix, "")
        self.assertEqual(target_match.includes_ljmmm, True)
Exemple #26
0
    def test_title_field(self):
        matches = parse_ljsl.find_names(
            "@registers(Test Section):TEST,REST#(0:1) "\
            "@registers(Test Section 2):TEST,REST#(0:1) "\
            "@registers:TEST,REST#(0:1) "
        )

        self.assertEqual(len(matches), 3)

        target_match = matches[0]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "Test Section")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "Test Section")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        target_match = matches[1]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "Test Section 2")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "Test Section 2")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        target_match = matches[2]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)
Exemple #27
0
    def test_title_field(self):
        matches = parse_ljsl.find_names(
            "@registers(Test Section):TEST,REST#(0:1) "\
            "@registers(Test Section 2):TEST,REST#(0:1) "\
            "@registers:TEST,REST#(0:1) "
        )

        self.assertEqual(len(matches), 3)

        target_match = matches[0]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "Test Section")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "Test Section")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        target_match = matches[1]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "Test Section 2")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "Test Section 2")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)

        target_match = matches[2]
        self.assertEqual(len(target_match), 2)
        self.assertEqual(target_match[0].title, "")
        self.assertEqual(target_match[0].prefix, "TEST")
        self.assertEqual(target_match[0].start_num, None)
        self.assertEqual(target_match[0].num_regs, None)
        self.assertEqual(target_match[0].num_between_regs, None)
        self.assertEqual(target_match[0].postfix, None)
        self.assertEqual(target_match[0].includes_ljmmm, False)

        self.assertEqual(target_match[1].title, "")
        self.assertEqual(target_match[1].prefix, "REST")
        self.assertEqual(target_match[1].start_num, 0)
        self.assertEqual(target_match[1].num_regs, 1)
        self.assertEqual(target_match[1].num_between_regs, None)
        self.assertEqual(target_match[1].postfix, "")
        self.assertEqual(target_match[1].includes_ljmmm, True)
Exemple #28
0
 def test_find_names(self):
     matches = parse_ljsl.find_names(TEST_CORPUS)
     self.corpus_matches_tests(matches)
 def test_find_names(self):
     matches = parse_ljsl.find_names(TEST_CORPUS)
     self.corpus_matches_tests(matches)