Skip to content

Commit fdca15e

Browse files
committed
Add a unit test for package summary
Signed-off-by: swastik <swastkk@gmail.com>
1 parent 3ca4308 commit fdca15e

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Sample code
2+
3+
Copyright Example Corp.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Permission is hereby granted, free of charge, to any person obtaining
2+
a copy of this software and associated documentation files (the
3+
"Software"), to deal in the Software without restriction, including
4+
without limitation the rights to use, copy, modify, merge, publish,
5+
distribute, sublicense, and/or sell copies of the Software, and to
6+
permit persons to whom the Software is furnished to do so, subject to
7+
the following conditions:
8+
9+
The above copyright notice and this permission notice shall be
10+
included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright Example Corp
2+
# Copyright Other Corp.
3+
# This is licensed under Apache-2.0 or MIT
4+
5+
def something():
6+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright Example Corp.
2+
# This is licensed under GPL-2.0-or-later
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"files": [
3+
{
4+
"path": "codebase",
5+
"type": "directory",
6+
"scan_errors": []
7+
},
8+
{
9+
"path": "codebase/mit.LICENSE",
10+
"type": "file",
11+
"scan_errors": []
12+
},
13+
{
14+
"path": "codebase/README.txt",
15+
"type": "file",
16+
"scan_errors": []
17+
},
18+
{
19+
"path": "codebase/src",
20+
"type": "directory",
21+
"scan_errors": []
22+
},
23+
{
24+
"path": "codebase/src/a.py",
25+
"type": "file",
26+
"scan_errors": []
27+
},
28+
{
29+
"path": "codebase/tests",
30+
"type": "directory",
31+
"scan_errors": []
32+
},
33+
{
34+
"path": "codebase/tests/test_a.py",
35+
"type": "file",
36+
"scan_errors": []
37+
}
38+
]
39+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
import pytest
11+
from os import path
12+
13+
from commoncode.testcase import FileDrivenTesting
14+
from scancode.cli_test_utils import check_json_scan
15+
from scancode.cli_test_utils import run_scan_click
16+
from scancode_config import REGEN_TEST_FIXTURES
17+
from summarycode.package_summary import PackageSummary
18+
19+
class TestPackageSummary(FileDrivenTesting):
20+
test_data_dir = path.join(path.dirname(__file__), 'data')
21+
22+
def test_package_summary_plugin(self):
23+
test_dir = self.get_test_loc('package_summary/basic-plugin-testing/codebase/')
24+
result_file = self.get_temp_file('json')
25+
expected_file = self.get_test_loc('package_summary/basic-plugin-testing/expected.json')
26+
27+
# Run the scan with the package summary option
28+
run_scan_click([
29+
'--package-summary',
30+
'--json-pp', result_file, test_dir
31+
])
32+
33+
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

0 commit comments

Comments
 (0)