
    j                         d Z ddlZddlmc mZ ddlZddlm	Z	 dZ
dZdZd Zd Zd	 Zd
 Zej"                  j%                  d      d        Zy)u   
TDD spec for duplicate_detector.flag_duplicates().

Written BEFORE the first Alembic migration (AR-2 compliance).
Tests use only plain Python — no DB, no Flask app context required.
    N)flag_duplicatesaaa111bbb222ccc333c                     t        t        gt        t        g      } dg}| |k(  }|st        j                  d|fd| |f      dt        j                         v st        j                  |       rt        j                  |       ndt        j                  |      dz  }dd|iz  }t        t        j                  |            dx}}y)	zFA new fingerprint that exists in existing set is flagged as duplicate.T==z%(py0)s == %(py3)sresultpy0py3assert %(py5)spy5Nr   HASH_AHASH_B
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   @py_assert2@py_assert1@py_format4@py_format6s        G/var/www/html/financials/tests/test_services/test_duplicate_detector.pytest_exact_match_detectedr"      sp    fX'78FV6V6V66V    c                     t        t        gt        t        g      } dg}| |k(  }|st	        j
                  d|fd| |f      dt        j                         v st	        j                  |       rt	        j                  |       ndt	        j                  |      dz  }dd|iz  }t        t	        j                  |            dx}}y)	z9A new fingerprint not in the existing set is not flagged.Fr   r
   r   r   r   r   N)r   HASH_Cr   r   r   r   r   r   r   r   r   r   r   s        r!   test_no_matchr&      sp    fX'78FW6W6W66Wr#   c                  |   t        g t        t        g      } g }| |k(  }|st        j                  d|fd| |f      dt        j                         v st        j                  |       rt        j                  |       ndt        j                  |      dz  }dd|iz  }t        t        j                  |            dx}}y)z"Empty input produces empty output.r   r
   r   r   r   r   Nr   r   s        r!   .test_empty_new_fingerprints_returns_empty_listr(      sk    R&&!12F6R<6R66Rr#   c                     t        t        t        gg       } ddg}| |k(  }|st        j                  d|fd| |f      dt        j                         v st        j                  |       rt        j                  |       ndt        j                  |      dz  }dd|iz  }t        t        j                  |            dx}}y)	z:No existing transactions means nothing can be a duplicate.Fr   r
   r   r   r   r   Nr   r   s        r!   2test_empty_existing_fingerprints_returns_all_falser*   "   sp    ff-r2FU^#6^####6^######6###6###^#######r#   zwired in Epic 9c                       y)u  
    Staged transactions must be checked against BOTH the staging DB and the main DB.

    Implementation note (Epic 9):
      - staging_pipeline.begin_import() collects existing hashes from:
          1. Current import batch's staged rows (catches intra-batch dupes)
          2. Main DB transactions within ±3-day window of each new transaction's date
      - Both sets are merged before calling flag_duplicates()
      - This ensures statement-period overlaps across multiple imports are caught
    N r,   r#   r!   test_staged_vs_main_dedup_pathr-   (   s     	r#   )__doc__builtinsr   _pytest.assertion.rewrite	assertionrewriter   pytestapp.services.duplicate_detectorr   r   r   r%   r"   r&   r(   r*   markskipr-   r,   r#   r!   <module>r7      s_      ; 
		$ #$	 %	r#   