Skip to content

Commit

Permalink
Remove dead code.
Browse files Browse the repository at this point in the history
Measurement.summarize_latest() would include a `measurement_requested` flag in the measurement summary if the metric of the measurement had a `measurement_requested` timestamp. However, as the frontend is not using that measurement flag, but instead looking at the metric's `measurement_requested` timestamp directly, the flag is superfluous.
  • Loading branch information
fniessink committed Sep 23, 2024
1 parent c01e807 commit c8d4afa
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 54 deletions.
2 changes: 0 additions & 2 deletions components/shared_code/src/shared/model/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,6 @@ def summarize_latest(self) -> Self:
if parameter_hash != self.metric.source_parameter_hash():
self["outdated"] = True
del self["source_parameter_hash"]
if measurement_requested := self.metric.get("measurement_requested"):
self["measurement_requested"] = measurement_requested >= self["end"]
return self

def source_parameter_hash(self) -> str:
Expand Down
23 changes: 0 additions & 23 deletions components/shared_code/tests/shared/model/test_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,29 +485,6 @@ def test_summarize_with_non_default_start_date(self):
measurement.summarize(),
)

def test_summarize_latest_with_old_measurement_request(self):
"""Test that the measurement includes the measurement requested flag when a measurement was requested."""
now = datetime.now(tz=UTC).replace(microsecond=0)
just_now = (now - timedelta(seconds=1)).isoformat()
metric = self.metric(measurement_requested=just_now)
measurement = self.measurement(metric, start=now.isoformat(), end=now.isoformat())
self.assertFalse(measurement.summarize_latest()["measurement_requested"])

def test_summarize_latest_with_new_measurement_request(self):
"""Test that the measurement includes the measurement requested flag when a measurement was requested."""
now = datetime.now(tz=UTC).replace(microsecond=0)
just_now = (now - timedelta(seconds=1)).isoformat()
metric = self.metric(measurement_requested=now.isoformat())
measurement = self.measurement(metric, start=just_now, end=just_now)
self.assertTrue(measurement.summarize_latest()["measurement_requested"])

def test_summarize_latest_without_measurement_request(self):
"""Test that the measurement has no measurement requested flag when no measurement was requested."""
now = datetime.now(tz=UTC).replace(microsecond=0).isoformat()
metric = self.metric()
measurement = self.measurement(metric, start=now, end=now)
self.assertNotIn("measurement_requested", measurement.summarize_latest())


class CalculateMeasurementValueTest(MeasurementTestCase):
"""Unit tests for calculating the measurement value from one or more source measurements."""
Expand Down
1 change: 0 additions & 1 deletion docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ If your currently installed *Quality-time* version is not v5.16.0, please first
### Fixed

- Work around a [bug in aiohttp](https://github.com/aio-libs/aiohttp/issues/2217) that causes Dependency-Track connections to hang and timeout when the Dependency-Track data is paginated. Fixes [#9599](https://github.com/ICTU/quality-time/issues/9599).
- Show the hour glass icon when copying a metric with a source. Fixes [#9631](https://github.com/ICTU/quality-time/issues/9631).

## v5.16.0 - 2024-09-19

Expand Down
11 changes: 0 additions & 11 deletions tests/feature_tests/src/features/metric.feature
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,3 @@ Feature: metric
Given an existing metric
When the client changes the metric comment to "Text<script>alert('Danger')</script>"
Then the metric comment is "Text"

Scenario: request measurement
Given an existing metric
And an existing source
And the collector has measured "100"
When the client requests the metric to be measured
Then the metric is being measured
When the client waits a second
And the collector measures "100"
And the client waits a second
Then the metric is not being measured
17 changes: 0 additions & 17 deletions tests/feature_tests/src/steps/metric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Feature tests for metric specific attributes."""

from datetime import UTC, datetime

from asserts import assert_equal, assert_false, assert_is_none, assert_is_not_none, assert_true
from behave import then, when
from behave.runner import Context
Expand Down Expand Up @@ -65,21 +63,6 @@ def do_not_accept_technical_debt(context: Context) -> None:
context.post(f"metric/{context.uuid['metric']}/debt", json={"accept_debt": False})


@when("the client requests the metric to be measured")
def measurement_request(context: Context) -> None:
"""Request a metric to be measured."""
now = datetime.now(tz=UTC).replace(microsecond=0).isoformat()
attribute_endpoint = f"metric/{context.uuid['metric']}/attribute/measurement_requested"
context.post(attribute_endpoint, json={"measurement_requested": now})


@then("the metric is {being} measured")
def assert_metric_is_being_measured(context: Context, being: str) -> None:
"""Assert that the metric is 'being' measured' or is 'not being' measured."""
metric = get_item(context, "metric")
assert_equal(bool(being == "being"), metric["latest_measurement"]["measurement_requested"])


@then("the metric technical debt end date is empty")
def assert_metric_technical_debt_end_date_is_empty(context: Context) -> None:
"""Assert the metric technical debt end date is empty."""
Expand Down

0 comments on commit c8d4afa

Please sign in to comment.