Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/api_server/src/model/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from shared.model.iterators import issue_trackers, sources
from shared.model.source import PASSWORD_PARAMETERS
from shared_data_model.parameters import PASSWORD_PARAMETERS

from .queries import is_password_parameter

Expand Down
20 changes: 20 additions & 0 deletions components/api_server/src/model/source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Source context."""

from dataclasses import dataclass
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from model.report import Report
from shared.model.metric import Metric
from shared.model.source import Source
from shared.model.subject import Subject


@dataclass
class SourceContext:
"""Source, combined with its containing metric, subject, and report."""

metric: Metric
report: Report
source: Source
subject: Subject
3 changes: 2 additions & 1 deletion components/api_server/src/model/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from shared.utils.type import ItemId, MetricId, ReportId, SourceId, SubjectId

from model.report import Report
from utils.type import EditScope, SourceContext
from model.source import SourceContext
from utils.type import EditScope


CREDENTIALS_REPLACEMENT_TEXT = "this string replaces credentials"
Expand Down
3 changes: 1 addition & 2 deletions components/api_server/src/routes/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import bottle

from shared.model.source import CREDENTIAL_PARAMETERS, PASSWORD_PARAMETERS
from shared_data_model import DATA_MODEL
from shared_data_model.parameters import PrivateToken
from shared_data_model.parameters import CREDENTIAL_PARAMETERS, PASSWORD_PARAMETERS, PrivateToken

from database.datamodels import latest_datamodel
from database.measurements import recent_measurements
Expand Down
3 changes: 2 additions & 1 deletion components/api_server/src/routes/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
from model.actions import copy_source, move_item
from model.defaults import default_source_parameters
from model.queries import is_password_parameter
from model.source import SourceContext
from model.transformations import change_source_parameter
from utils.functions import check_url_availability, uuid
from utils.type import EditScope, SourceContext
from utils.type import EditScope

from .plugins.auth_plugin import EDIT_REPORT_PERMISSION

Expand Down
15 changes: 0 additions & 15 deletions components/api_server/src/utils/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
if TYPE_CHECKING:
from datetime import datetime

from model.report import Report
from shared.model.metric import Metric
from shared.model.source import Source
from shared.model.subject import Subject

Change = dict[str, str | dict[str, str]]
EditScope = Literal["source", "report"]
Position = Literal["first", "last", "next", "previous"]
Expand Down Expand Up @@ -51,13 +46,3 @@ class SessionData(TypedDict, total=False):
email: str
common_name: str
session_expiration_datetime: datetime


@dataclass
class SourceContext:
"""Source, combined with its containing metric, subject, and report."""

metric: Metric
report: Report
source: Source
subject: Subject
2 changes: 1 addition & 1 deletion components/api_server/tests/model/test_transformations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Model transformation unit tests."""

from model.source import SourceContext
from model.report import Report
from model.transformations import change_source_parameter, hide_credentials, CREDENTIALS_REPLACEMENT_TEXT

from tests.base import DataModelTestCase
from tests.fixtures import create_report, METRIC_ID2, SUBJECT_ID, METRIC_ID, REPORT_ID, SOURCE_ID, SOURCE_ID2
from utils.type import SourceContext


class HideCredentialsTest(DataModelTestCase):
Expand Down
13 changes: 13 additions & 0 deletions components/api_server/tests/test_architecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Test the architecture of the component."""

import unittest

from archunitpython import assert_passes, project_files


class DependenciesTest(unittest.TestCase):
"""Unit test for module dependencies within the component."""

def test_no_cyclic_dependencies(self):
"""Test that there are no cyclic dependencies."""
assert_passes(project_files("src/").should().have_no_cycles())
11 changes: 11 additions & 0 deletions components/api_server/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/collector/src/base_collectors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Metric collectors."""

from .api_source_collector import JenkinsPluginCollector, JenkinsPluginSourceUpToDatenessCollector
from .collector import Collector
from .file_source_collector import (
CSVFileSourceCollector,
FileSourceCollector,
Expand Down
3 changes: 2 additions & 1 deletion components/collector/src/quality_time_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# Make sure subclasses are registered
import metric_collectors # noqa: F401
import source_collectors # noqa: F401
from base_collectors import Collector, config
from base_collectors import config
from base_collectors.collector import Collector


async def collect() -> NoReturn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from shared.utils.functions import iso_timestamp

import quality_time_collector
from base_collectors import Collector, config
from base_collectors.collector import Collector, config

from tests.fixtures import METRIC_ID, METRIC_ID2, SOURCE_ID, SUBJECT_ID, create_report

Expand Down
13 changes: 13 additions & 0 deletions components/collector/tests/test_architecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Test the architecture of the component."""

import unittest

from archunitpython import assert_passes, project_files


class DependenciesTest(unittest.TestCase):
"""Unit test for module dependencies within the component."""

def test_no_cyclic_dependencies(self):
"""Test that there are no cyclic dependencies."""
assert_passes(project_files("src/").should().have_no_cycles())
6 changes: 3 additions & 3 deletions components/collector/tests/test_quality_time_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
class CollectorTestCase(unittest.IsolatedAsyncioTestCase):
"""Unit tests for starting the collector."""

@patch("base_collectors.Collector.start")
@patch("base_collectors.collector.Collector.start")
async def test_start(self, mocked_start):
"""Test that the collector is started."""
await collect()
mocked_start.assert_called_once()

@patch("base_collectors.Collector.start", AsyncMock())
@patch("base_collectors.collector.Collector.start", AsyncMock())
async def test_default_log_level(self):
"""Test the default logging level."""
await collect()
self.assertEqual("WARNING", logging.getLevelName(logging.getLogger().getEffectiveLevel()))

@patch("base_collectors.Collector.start", AsyncMock())
@patch("base_collectors.collector.Collector.start", AsyncMock())
@patch("base_collectors.config.LOG_LEVEL", "DEBUG")
async def test_change_log_level(self):
"""Test that the logging level can be changed."""
Expand Down
11 changes: 11 additions & 0 deletions components/collector/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions components/notifier/tests/test_architecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Test the architecture of the component."""

import unittest

from archunitpython import assert_passes, project_files


class DependenciesTest(unittest.TestCase):
"""Unit test for module dependencies within the component."""

def test_no_cyclic_dependencies(self):
"""Test that there are no cyclic dependencies."""
assert_passes(project_files("src/").should().have_no_cycles())
11 changes: 11 additions & 0 deletions components/notifier/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions components/shared_code/src/shared/model/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
from .metric import Metric


PASSWORD_PARAMETERS = {"password", "private_token"}
CREDENTIAL_PARAMETERS = {*PASSWORD_PARAMETERS, "username"}


class Source(dict):
"""Class representing a measurement source."""

Expand Down
2 changes: 1 addition & 1 deletion components/shared_code/src/shared/model/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def delete_tag(self, tag: str) -> list[MetricId]:
return uuids

def rename_tag(self, tag: str, new_tag: str) -> list[MetricId]:
"""Rename a tag in the report and return the UUIDs of the affected metrics."""
"""Rename a tag in the subject and return the UUIDs of the affected metrics."""
uuids = []
for metric_uuid, metric in self.metrics_dict.items():
if metric.rename_tag(tag, new_tag):
Expand Down
5 changes: 3 additions & 2 deletions components/shared_code/src/shared_data_model/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

from pydantic import model_validator

from shared.model.source import CREDENTIAL_PARAMETERS

from .meta.parameter import Parameter, ParameterType
from .meta.unit import Unit

PASSWORD_PARAMETERS = {"password", "private_token"}
CREDENTIAL_PARAMETERS = {*PASSWORD_PARAMETERS, "username"}


class DateParameter(Parameter):
"""Date parameter."""
Expand Down
20 changes: 20 additions & 0 deletions components/shared_code/tests/test_architecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Test the architecture of the component."""

import unittest

from archunitpython import CheckOptions, assert_passes, project_files


class DependenciesTest(unittest.TestCase):
"""Unit test for module dependencies within the component."""

def test_no_cyclic_dependencies(self):
"""Test that there are no cyclic dependencies."""
assert_passes(project_files("src/").should().have_no_cycles(), CheckOptions(ignore_type_checking_imports=True))

def test_shared_data_model_meta_does_not_depend_on_anything(self):
"""Test that the meta model does not depend on the rest of the data model."""
files = project_files("src/")
meta = "src/shared_data_model/meta/*.py"
assert_passes(files.in_path(meta).should_not().depend_on_files().in_path("src/shared_data_model/sources/*.py"))
assert_passes(files.in_path(meta).should_not().depend_on_files().in_folder("src/shared_data_model"))
11 changes: 11 additions & 0 deletions components/shared_code/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ lint.per-file-ignores."src/create_reference_md.py" = [
]
lint.per-file-ignores."tests/**/*.py" = [
"ANN201", # https://docs.astral.sh/ruff/rules/missing-return-type-undocumented-public-function/ - don't require test functions to have return types
"ANN205", # https://docs.astral.sh/ruff/rules/missing-return-type-static-method/ - don't require static test methods to have return types
]
lint.isort.section-order = [
"future",
Expand Down
Loading