Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Sep 17, 2024
1 parent b841009 commit 52e650b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
# keep in sync with `cyclonedx/builder/this.py`
name = "cyclonedx-python-lib"
# !! version is managed by semantic_release
version = "7.6.0"
Expand Down Expand Up @@ -64,7 +63,6 @@ keywords = [
]

[tool.poetry.urls]
# keep in sync with `cyclonedx/builder/this.py`
"Bug Tracker" = "https://github.com/CycloneDX/cyclonedx-python-lib/issues"
"Funding" = "https://owasp.org/donate/?reponame=www-project-cyclonedx&title=OWASP+CycloneDX"

Expand Down
15 changes: 10 additions & 5 deletions tests/test_builder_this.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.

from typing import Any, Dict, Iterable, Tuple
from typing import Any, Dict, Iterable, Tuple, Union
from unittest import TestCase

from cyclonedx.builder.this import this_component, this_tool
Expand All @@ -25,22 +25,27 @@
from tests import load_pyproject


class TestThisBase(TestCase):
class ExtRefsTestMixin:

@staticmethod
def __first_ers_uri(t: ExternalReferenceType, ers: Iterable[ExternalReference]) -> str:
return next(filter(lambda r: r.type is t, ers)).url.uri

def assertExtRefs(self, p: Dict[str, Any], ers: Iterable[ExternalReference]) -> None: # noqa:N802
def assertExtRefs( # noqa:N802
self: Union[TestCase, 'ExtRefsTestMixin'],
p: Dict[str, Any], ers: Iterable[ExternalReference]
) -> None:
self.assertEqual(p['tool']['poetry']['homepage'], self.__first_ers_uri(
ExternalReferenceType.WEBSITE, ers))
self.assertEqual(p['tool']['poetry']['repository'], self.__first_ers_uri(
ExternalReferenceType.VCS, ers))
self.assertEqual(p['tool']['poetry']['documentation'], self.__first_ers_uri(
ExternalReferenceType.DOCUMENTATION, ers))
self.assertEqual(p['tool']['poetry']['urls']['Bug Tracker'], self.__first_ers_uri(
ExternalReferenceType.ISSUE_TRACKER, ers))


class TestThisComponent(TestThisBase):
class TestThisComponent(TestCase, ExtRefsTestMixin):
def test_basics(self) -> None:
p = load_pyproject()
c = this_component()
Expand All @@ -65,7 +70,7 @@ def test_extrefs(self) -> None:
self.assertExtRefs(p, ers)


class TestThisTool(TestThisBase):
class TestThisTool(TestCase, ExtRefsTestMixin):
def test_basics(self) -> None:
p = load_pyproject()
t = this_tool()
Expand Down

0 comments on commit 52e650b

Please sign in to comment.