Exemple #1
0
def test_get_dict():
    detection = Detection(examples_path, '.')
    extension = ['php', 'js', 'java']
    type_num = {}
    type_num = detection.get_dict(extension, type_num)
    print(type(type_num))
    assert type_num['php']['blank'] == 0
def test_get_dict():
    detection = Detection(examples_path, '.')
    extension = ['php', 'js', 'java']
    type_num = {}
    type_num = detection.get_dict(extension, type_num)
    print(type(type_num))
    assert type_num['php']['blank'] == 0
Exemple #3
0
def test_param_xml():
    detection = Detection(examples_path, '.')
    frame_data = {}
    language_data = {}
    tree = detection.rule()
    root = tree.getroot()
    frame_data, language_data = detection.parse_xml(root, frame_data, language_data)
    assert 'WordPress' in frame_data
    assert 'php' in language_data
Exemple #4
0
def test_param_xml():
    detection = Detection(examples_path, '.')
    frame_data = {}
    language_data = {}
    tree = detection.rule()
    root = tree.getroot()
    frame_data, language_data = detection.parse_xml(root, frame_data, language_data)
    assert 'WordPress' in frame_data
    assert 'php' in language_data
def test_count_total_num():
    type_num = {
        'php': {
            'blank': 10,
            'code': 10,
            'pound': 10,
            'files': 2
        },
        'java': {
            'blank': 10,
            'code': 10,
            'pound': 10,
            'files': 2
        }
    }
    extension = ['php', 'java']
    total_file = 0
    total_blank_line = 0
    total_pound_line = 0
    total_code_line = 0
    total_file, total_blank_line, total_pound_line, total_code_line = Detection.count_total_num(
        type_num, extension, total_file, total_blank_line, total_pound_line,
        total_code_line)
    assert isinstance(total_file, int)
    assert isinstance(total_blank_line, int)
    assert isinstance(total_pound_line, int)
    assert isinstance(total_code_line, int)
Exemple #6
0
def test_count_total_num():
    type_num = {'php': {'blank': 10, 'code': 10, 'pound': 10, 'files': 2},
                'java': {'blank': 10, 'code': 10, 'pound': 10, 'files': 2}}
    extension = ['php', 'java']
    total_file = 0
    total_blank_line = 0
    total_pound_line = 0
    total_code_line = 0
    total_file, total_blank_line, total_pound_line, total_code_line = Detection.count_total_num(type_num, extension,
                                                                                                total_file,
                                                                                                total_blank_line,
                                                                                                total_pound_line,
                                                                                                total_code_line)
    assert isinstance(total_file, int)
    assert isinstance(total_blank_line, int)
    assert isinstance(total_pound_line, int)
    assert isinstance(total_code_line, int)
Exemple #7
0
def test_count_html_line():
    count = Detection.count_html_line(examples_path + '/cloc.html')
    type_ = count.keys()
    type_count = ['count_blank', 'count_code', 'count_pound']
    assert type_ == type_count
def test_count_data_line():
    count = Detection.count_data_line(examples_path + '/param_xml.xml')
    type_count = ['count_blank', 'count_code', 'count_pound']
    assert count['count_code'] == 81
def test_countnum():
    count = {'count_blank': 10, 'count_code': 20, 'count_pound': 30}
    type_num = {'php': {'blank': 10, 'code': 10, 'pound': 10, 'files': 2}}
    ext = 'php'
    type_num = Detection.countnum(count, type_num, ext)
    assert 'php' in type_num
def test_project_information():
    extension = ['php', 'js', 'java']
    allfiles = Detection.project_information(examples_path, extension)
    assert examples_path + '/cloc.html' in allfiles
def test_count_java_line():
    count = Detection.count_java_line(examples_path + '/cloc.java')
    type_count = ['count_blank', 'count_code', 'count_pound']
    assert count['count_code'] == 1
def test_rule():
    detection = Detection(examples_path, '.')
    root = eT.ElementTree(file=examples_path + '/param_xml.xml')
    tree = detection.rule()
    assert type(root) is type(tree)
Exemple #13
0
def test_rule():
    detection = Detection(examples_path, '.')
    root = eT.ElementTree(file=examples_path+'/param_xml.xml')
    tree = detection.rule()
    assert type(root) is type(tree)
def test_cloc():
    assert Detection(examples_path, '.').cloc()
def test_framework():
    detection = Detection(vul_path + 'requirements.txt', '.')
    frame = detection.framework
    assert frame == 'Flask'
Exemple #16
0
def test_project_information():
    extension = ['php', 'js', 'java']
    allfiles = Detection.project_information(examples_path, extension)
    assert examples_path+'/cloc.html' in allfiles
Exemple #17
0
def test_get_dict():
    detection = Detection(examples_path, '.')
    extension = ['php', 'js', 'java']
    type_num = {}
    type_num = detection.get_dict(extension, type_num)
    assert isinstance(extension, type(type_num.keys()))
Exemple #18
0
def test_count_html_line():
    count = Detection.count_html_line(examples_path+'/cloc.html')
    type_count = ['count_blank', 'count_code', 'count_pound']
    assert count['count_code'] == 9
Exemple #19
0
def test_countnum():
    count = {'count_blank': 10, 'count_code': 20, 'count_pound': 30}
    type_num = {'php': {'blank': 10, 'code': 10, 'pound': 10, 'files': 2}}
    ext = 'php'
    type_num = Detection.countnum(count, type_num, ext)
    assert 'php' in type_num
Exemple #20
0
def test_count_data_line():
    count = Detection.count_data_line(examples_path+'/param_xml.xml')
    type_count = ['count_blank', 'count_code', 'count_pound']
    assert count['count_code'] == 81