fix: 移除干扰来源字段
This commit is contained in:
@@ -11,9 +11,8 @@ import unittest
|
||||
from unittest.mock import patch
|
||||
import zipfile
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
import main
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
COMPLETE_WINDOW = "2026073110001100"
|
||||
@@ -38,8 +37,8 @@ class PipelineTest(unittest.TestCase):
|
||||
with (result / f"interference_summary_{COMPLETE_WINDOW}.csv").open(encoding="utf-8-sig", newline="") as file:
|
||||
rows = list(csv.DictReader(file))
|
||||
self.assertEqual(len(rows), 7)
|
||||
self.assertEqual({row["source_type"] for row in rows}, set(main.EXPECTED_TYPES))
|
||||
rows_by_type = {row["source_type"]: row for row in rows}
|
||||
self.assertEqual(list(rows[0]), ["hour_start", "hour_end", "cgi", "cell_name", "interference_dbm"])
|
||||
rows_by_type = {row["cell_name"].removesuffix("-小区"): row for row in rows}
|
||||
self.assertEqual(rows_by_type["5G干扰监控"]["cgi"], "460-00-200-1")
|
||||
self.assertEqual(rows_by_type["700M干扰监控"]["cgi"], "460-00-200-1")
|
||||
for source_type in set(main.EXPECTED_TYPES) - {"5G干扰监控", "700M干扰监控"}:
|
||||
@@ -51,6 +50,8 @@ class PipelineTest(unittest.TestCase):
|
||||
self.assertEqual(manifest["summary_rows"], 7)
|
||||
self.assertEqual(len(manifest["warnings"]), 1)
|
||||
self.assertIn(INCOMPLETE_WINDOW, manifest["warnings"][0])
|
||||
self.assertNotIn("source_types", manifest)
|
||||
self.assertTrue(all("source_type" not in item and "source_path" not in item for item in manifest["files"]))
|
||||
self.assertEqual(manifest["database"]["metric_time"], "2026-07-31 10:00:00")
|
||||
self.assertEqual(len(store.rows), 7)
|
||||
|
||||
@@ -91,6 +92,8 @@ class PipelineTest(unittest.TestCase):
|
||||
self.assertTrue(connection.committed)
|
||||
self.assertFalse(connection.rolled_back)
|
||||
self.assertTrue(connection.closed)
|
||||
self.assertNotIn("source_type", " ".join(connection.cursor_instance.queries))
|
||||
self.assertNotIn("source_path", " ".join(connection.cursor_instance.queries))
|
||||
|
||||
def test_mysql_store_refuses_to_replace_a_newer_hour(self) -> None:
|
||||
connection = FakeConnection(datetime(2026, 7, 31, 11))
|
||||
@@ -147,10 +150,12 @@ class FakeCursor:
|
||||
self.old_rows = old_rows
|
||||
self.rowcount = 0
|
||||
self.inserted: list[tuple[object, ...]] = []
|
||||
self.queries: list[str] = []
|
||||
self.closed = False
|
||||
|
||||
def execute(self, query: str, params: tuple[object, ...] | None = None) -> None:
|
||||
normalized = " ".join(query.split())
|
||||
self.queries.append(normalized)
|
||||
if normalized.startswith("DELETE") and "metric_time = %s" in normalized:
|
||||
self.rowcount = self.same_hour_rows
|
||||
elif normalized.startswith("DELETE") and "metric_time <> %s" in normalized:
|
||||
@@ -216,11 +221,9 @@ def database_row() -> dict[str, str]:
|
||||
return {
|
||||
"hour_start": "2026-07-31 10:00:00",
|
||||
"hour_end": "2026-07-31 11:00:00",
|
||||
"source_type": "5G干扰监控",
|
||||
"cgi": "460-00-200-1",
|
||||
"cell_name": "测试小区",
|
||||
"interference_dbm": "-100.5",
|
||||
"source_path": "/source.zip",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user