Skip to content

Commit 40d7d5b

Browse files
authored
Fix the logger issue (#205)
Signed-off-by: jiyeong.seok <[email protected]>
1 parent 50b13e9 commit 40d7d5b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/fosslight_util/write_cyclonedx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
1818
from packageurl import PackageURL
1919
import traceback
20+
21+
logger = logging.getLogger(LOGGER_NAME)
22+
2023
try:
2124
from cyclonedx.builder.this import this_component as cdx_lib_component
2225
from cyclonedx.exception import MissingOptionalDependencyException
@@ -35,7 +38,6 @@
3538
from cyclonedx.validation.xml import XmlValidator
3639
except Exception:
3740
logger.info('No import cyclonedx-python-lib')
38-
logger = logging.getLogger(LOGGER_NAME)
3941

4042

4143
def write_cyclonedx(output_file_without_ext, output_extension, scan_item):

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def scan_item():
3636
scan_item.set_cover_comment('This is a test comment')
3737

3838
file_item = FileItem('test_result/excel_and_csv')
39+
file_item.checksum = 'af969fc2085b1bb6d31e517d5c456def5cdd7093'
3940

4041
oss_item = OssItem("test_name1", "1.0.0", "Apache-2.0", "https://abc.com")
4142
oss_item.comment = "test_name comment"

tests/test_cyclonedx.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2021 LG Electronics Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import os
5+
6+
from fosslight_util.write_cyclonedx import write_cyclonedx
7+
from tests import constants
8+
9+
10+
def test_cyclonedx(scan_item):
11+
# given
12+
output_dir = os.path.join(constants.TEST_RESULT_DIR, "cyclonedx")
13+
filename_with_dir = os.path.join(output_dir, "FL-TEST_cyclonedx.json")
14+
15+
# when
16+
success, err_msg, _ = write_cyclonedx(filename_with_dir.split('.')[0], '.json', scan_item)
17+
18+
# then
19+
assert success is True
20+
assert len(os.listdir(output_dir)) > 0

0 commit comments

Comments
 (0)