forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_generated.py
More file actions
92 lines (77 loc) · 3.85 KB
/
test_generated.py
File metadata and controls
92 lines (77 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import os
from commoncode.testcase import FileBasedTesting
from scancode.cli_test_utils import check_json_scan
from scancode.cli_test_utils import run_scan_click
from scancode_config import REGEN_TEST_FIXTURES
from summarycode import generated
class TestGeneratedCode(FileBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
def test_basic(self):
expected = [
'// This file was generated by the JavaTM Architecture '.lower() +
'for XML Binding(JAXB) Reference Implementation'.lower(),
'// Generated on: 2011.08.01 at 11:35:59 AM CEST'.lower()
]
test_file = self.get_test_loc('generated/simple/generated_1.java')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_basic_alt(self):
expected = [
'// This file was generated by the JavaTM Architecture '.lower() +
'for XML Binding(JAXB) Reference Implementation'.lower(),
'// Generated on: 2013.11.15 at 04:17:00 PM CET'.lower()
]
test_file = self.get_test_loc('generated/simple/generated_3.java')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_basic2(self):
expected = ['* This class was generated by the JAX-WS RI.'.lower()]
test_file = self.get_test_loc('generated/simple/generated_2.java')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_basic3(self):
expected = ['/* This class was automatically generated'.lower()]
test_file = self.get_test_loc('generated/simple/generated_4.java')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_basic4(self):
expected = [
'* <p>The following schema fragment specifies the '.lower() +
'expected content contained within this class.'.lower()
]
test_file = self.get_test_loc('generated/simple/generated_5.java')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_basic5(self):
expected = ['/* DO NOT EDIT THIS FILE - it is machine generated */'.lower()]
test_file = self.get_test_loc('generated/simple/generated_6.c')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_configure(self):
expected = [
'# Generated by GNU Autoconf 2.64 for Apache CouchDB 1.0.1.'.lower()
]
test_file = self.get_test_loc('generated/simple/configure')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_tomcat_jspc(self):
expected = [
'<!--Automatically created by Apache Jakarta Tomcat JspC.'.lower()
]
test_file = self.get_test_loc('generated/jspc/web.xml')
result = list(generated.get_generated_code_hint(location=test_file))
assert result == expected
def test_generated_cli_option(self):
test_dir = self.get_test_loc('generated/simple')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('generated/cli.expected.json')
run_scan_click(['--generated', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)