Files
mongo/buildscripts/tests/monitor_build_status/test_cli.py
Mikhail Shchatko cfa71f3776 SERVER-93515 Apply new VP and Overall quotas for the code lockdown (#26106)
GitOrigin-RevId: 56309603a6e1d87c9caa8b78b3208104d9e76866
2024-08-14 15:34:13 +00:00

61 lines
2.0 KiB
Python

import unittest
import buildscripts.monitor_build_status.cli as under_test
class TestSummarize(unittest.TestCase):
def test_all_thresholds_below_100(self):
scope_percentages = {
"Scope 1": [0.0, 0.0, 0.0],
"Scope 2": [0.0, 0.0, 0.0],
"Scope 3": [0.0, 0.0, 0.0],
"Scope 4": [0.0, 0.0, 0.0],
}
summary = under_test.MonitorBuildStatusOrchestrator._summarize(scope_percentages)
expected_summary = (
f"{under_test.SummaryMsg.PREFIX.value} "
f"{under_test.SummaryMsg.BELOW_THRESHOLDS.value}\n\n"
f"{under_test.SummaryMsg.PLAYBOOK_REFERENCE.value}\n"
)
self.assertEqual(summary, expected_summary)
def test_all_thresholds_are_100(self):
scope_percentages = {
"Scope 1": [100.0, 100.0, 100.0],
"Scope 2": [100.0, 100.0, 100.0],
"Scope 3": [100.0, 100.0, 100.0],
"Scope 4": [100.0, 100.0, 100.0],
}
summary = under_test.MonitorBuildStatusOrchestrator._summarize(scope_percentages)
expected_summary = (
f"{under_test.SummaryMsg.PREFIX.value} "
f"{under_test.SummaryMsg.BELOW_THRESHOLDS.value}\n\n"
f"{under_test.SummaryMsg.PLAYBOOK_REFERENCE.value}\n"
)
self.assertEqual(summary, expected_summary)
def test_some_threshold_exceeded_100(self):
scope_percentages = {
"Scope 1": [101.0, 0.0, 0.0],
"Scope 2": [0.0, 101.0, 0.0],
"Scope 3": [0.0, 0.0, 101.0],
"Scope 4": [0.0, 0.0, 0.0],
}
summary = under_test.MonitorBuildStatusOrchestrator._summarize(scope_percentages)
expected_summary = (
f"{under_test.SummaryMsg.PREFIX.value} "
f"{under_test.SummaryMsg.THRESHOLD_EXCEEDED.value}\n"
f"\t- Scope 1\n\t- Scope 2\n\t- Scope 3\n\n"
f"{under_test.SummaryMsg.PLAYBOOK_REFERENCE.value}\n"
)
self.assertEqual(summary, expected_summary)