在准备环境前提交次全部更改。
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Property 5: 文件迁移完整性
|
||||
Property 5: 文件迁移完整性(已归档)
|
||||
|
||||
对于任意源-目标目录映射关系(ETL 业务代码、database 文件、tests 目录),
|
||||
原始用途:验证从 C:\\ZQYY\\FQ-ETL\\ 迁移到 NeoZQYY monorepo 时,
|
||||
源目录中的每个文件在目标目录的对应位置都应存在且内容一致。
|
||||
|
||||
归档原因:迁移已于 2025 年完成,后续多轮重构(dwd-phase1-refactor、
|
||||
etl-dws-flow-refactor、ods-dedup-standardize 等)对目标代码做了大量
|
||||
结构性修改,源-目标 1:1 对比前提不再成立。扫描显示 50+ 个文件已合理分化。
|
||||
|
||||
如需重新启用,可移除模块级 skip 标记。
|
||||
|
||||
**Validates: Requirements 5.1, 5.2, 5.3**
|
||||
"""
|
||||
import pytest
|
||||
|
||||
# 迁移已完成且目标代码经多轮重构已合理分化,此测试模块整体跳过
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="文件迁移已完成,后续重构导致源-目标合理分化(50+ 文件),测试使命结束"
|
||||
)
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
from typing import List, Tuple
|
||||
@@ -16,24 +29,20 @@ from hypothesis.strategies import sampled_from
|
||||
|
||||
# 源-目标目录映射(需求 5.1: ETL 业务代码,5.2: database,5.3: tests)
|
||||
MIGRATION_MAPPINGS: List[Tuple[str, str]] = [
|
||||
# ETL 业务代码目录(需求 5.1)
|
||||
(r"C:\ZQYY\FQ-ETL\api", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\api"),
|
||||
(r"C:\ZQYY\FQ-ETL\cli", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\cli"),
|
||||
(r"C:\ZQYY\FQ-ETL\config", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\config"),
|
||||
(r"C:\ZQYY\FQ-ETL\loaders", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\loaders"),
|
||||
(r"C:\ZQYY\FQ-ETL\models", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\models"),
|
||||
(r"C:\ZQYY\FQ-ETL\orchestration", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\orchestration"),
|
||||
(r"C:\ZQYY\FQ-ETL\scd", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\scd"),
|
||||
(r"C:\ZQYY\FQ-ETL\tasks", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\tasks"),
|
||||
(r"C:\ZQYY\FQ-ETL\utils", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\utils"),
|
||||
(r"C:\ZQYY\FQ-ETL\quality", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\quality"),
|
||||
# tests 子目录(需求 5.3)— 只映射 ETL 自身的 unit/integration,
|
||||
# Monorepo 级属性测试(test_property_*.py)按设计放在 C:\NeoZQYY\tests\
|
||||
(r"C:\ZQYY\FQ-ETL\tests\unit", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\tests\unit"),
|
||||
(r"C:\ZQYY\FQ-ETL\tests\integration", r"C:\NeoZQYY\apps\etl\pipelines\feiqiu\tests\integration"),
|
||||
(r"C:\ZQYY\FQ-ETL\api", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\api"),
|
||||
(r"C:\ZQYY\FQ-ETL\cli", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\cli"),
|
||||
(r"C:\ZQYY\FQ-ETL\config", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\config"),
|
||||
(r"C:\ZQYY\FQ-ETL\loaders", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\loaders"),
|
||||
(r"C:\ZQYY\FQ-ETL\models", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\models"),
|
||||
(r"C:\ZQYY\FQ-ETL\orchestration", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\orchestration"),
|
||||
(r"C:\ZQYY\FQ-ETL\scd", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\scd"),
|
||||
(r"C:\ZQYY\FQ-ETL\tasks", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\tasks"),
|
||||
(r"C:\ZQYY\FQ-ETL\utils", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\utils"),
|
||||
(r"C:\ZQYY\FQ-ETL\quality", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\quality"),
|
||||
(r"C:\ZQYY\FQ-ETL\tests\unit", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\tests\unit"),
|
||||
(r"C:\ZQYY\FQ-ETL\tests\integration", r"C:\NeoZQYY\apps\etl\connectors\feiqiu\tests\integration"),
|
||||
]
|
||||
|
||||
# 排除模式:__pycache__ 等不参与比较
|
||||
EXCLUDE_DIRS = {"__pycache__", ".pytest_cache", ".hypothesis"}
|
||||
|
||||
|
||||
@@ -67,7 +76,6 @@ def test_all_source_files_exist_in_target(mapping: Tuple[str, str]) -> None:
|
||||
**Validates: Requirements 5.1, 5.2, 5.3**
|
||||
"""
|
||||
src_dir, dst_dir = mapping
|
||||
|
||||
assert os.path.isdir(src_dir), f"源目录不存在: {src_dir}"
|
||||
assert os.path.isdir(dst_dir), f"目标目录不存在: {dst_dir}"
|
||||
|
||||
@@ -96,7 +104,6 @@ def test_source_and_target_file_content_identical(mapping: Tuple[str, str]) -> N
|
||||
**Validates: Requirements 5.1, 5.2, 5.3**
|
||||
"""
|
||||
src_dir, dst_dir = mapping
|
||||
|
||||
assert os.path.isdir(src_dir), f"源目录不存在: {src_dir}"
|
||||
assert os.path.isdir(dst_dir), f"目标目录不存在: {dst_dir}"
|
||||
|
||||
@@ -106,17 +113,13 @@ def test_source_and_target_file_content_identical(mapping: Tuple[str, str]) -> N
|
||||
for rel_path in src_files:
|
||||
src_path = os.path.join(src_dir, rel_path)
|
||||
dst_path = os.path.join(dst_dir, rel_path)
|
||||
|
||||
if not os.path.isfile(dst_path):
|
||||
continue
|
||||
|
||||
src_hash = _file_hash(src_path)
|
||||
dst_hash = _file_hash(dst_path)
|
||||
if src_hash != dst_hash:
|
||||
if _file_hash(src_path) != _file_hash(dst_path):
|
||||
mismatched.append(rel_path)
|
||||
|
||||
assert not mismatched, (
|
||||
f"源目录 {src_dir} 与目标目录 {dst_dir} 中 {len(mismatched)} 个文件内容不一致:\n"
|
||||
+ "\n".join(f" - {f}" for f in mismatched[:10])
|
||||
+ (f"\n ... 及其他 {len(mismatched) - 10} 个" if len(mismatched) > 10 else "")
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user