Exemplo n.º 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
Exemplo n.º 2
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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 5
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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 8
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
Exemplo n.º 9
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
Exemplo n.º 10
0
def test_project_information():
    extension = ['php', 'js', 'java']
    allfiles = Detection.project_information(examples_path, extension)
    assert examples_path + '/cloc.html' in allfiles
Exemplo n.º 11
0
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
Exemplo n.º 12
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)
Exemplo n.º 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)
Exemplo n.º 14
0
def test_cloc():
    assert Detection(examples_path, '.').cloc()
Exemplo n.º 15
0
def test_framework():
    detection = Detection(vul_path + 'requirements.txt', '.')
    frame = detection.framework
    assert frame == 'Flask'
Exemplo n.º 16
0
def test_project_information():
    extension = ['php', 'js', 'java']
    allfiles = Detection.project_information(examples_path, extension)
    assert examples_path+'/cloc.html' in allfiles
Exemplo n.º 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()))
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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