Skip to content

Commit

Permalink
Fix the logger issue (#205)
Browse files Browse the repository at this point in the history
Signed-off-by: jiyeong.seok <jiyeong.seok@lge.com>
  • Loading branch information
dd-jy authored Dec 4, 2024
1 parent 50b13e9 commit 40d7d5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fosslight_util/write_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
from packageurl import PackageURL
import traceback

logger = logging.getLogger(LOGGER_NAME)

try:
from cyclonedx.builder.this import this_component as cdx_lib_component
from cyclonedx.exception import MissingOptionalDependencyException
Expand All @@ -35,7 +38,6 @@
from cyclonedx.validation.xml import XmlValidator
except Exception:
logger.info('No import cyclonedx-python-lib')
logger = logging.getLogger(LOGGER_NAME)


def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def scan_item():
scan_item.set_cover_comment('This is a test comment')

file_item = FileItem('test_result/excel_and_csv')
file_item.checksum = 'af969fc2085b1bb6d31e517d5c456def5cdd7093'

oss_item = OssItem("test_name1", "1.0.0", "Apache-2.0", "https://abc.com")
oss_item.comment = "test_name comment"
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cyclonedx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0

import os

from fosslight_util.write_cyclonedx import write_cyclonedx
from tests import constants


def test_cyclonedx(scan_item):
# given
output_dir = os.path.join(constants.TEST_RESULT_DIR, "cyclonedx")
filename_with_dir = os.path.join(output_dir, "FL-TEST_cyclonedx.json")

# when
success, err_msg, _ = write_cyclonedx(filename_with_dir.split('.')[0], '.json', scan_item)

# then
assert success is True
assert len(os.listdir(output_dir)) > 0

0 comments on commit 40d7d5b

Please sign in to comment.