Ë
    Ì#,j#  ã                   óž   — d Z ddlZddlmc mZ ddlZddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZ d	efd
„Zd	e	fd„Z G d„ d«      Zy)zPIntegration test: full pipeline with CSV source, in-memory index, dry-run dgred.é    N©ÚSettings)ÚDgredClient)Ú	CsvSource)ÚCatalogIndex)ÚOffer)ÚPipelineÚreturnc                  ó¾   — t        d«      } t        dddddddd	d
dgd¬«
      t        dddddddddgd¬«
      t        dddddddg d¬«	      g}| j                  |«       | S ) Nú:memory:Ú1Úallegrozhttps://a.pl/1z#Pompa wody VOLVO FH13 D13A 20744939ÚVOLVOÚFH13ÚpompaÚD13AÚ20744939Ú20734268g      |@)
Úoffer_idÚplatformÚurlÚtitleÚbrandÚmodelÚcategoryÚengine_codeÚ
oe_numbersÚpriceÚ2Úebayzhttps://e.com/2z(Alternator OPEL Astra F C18NZ 0120488234ÚOPELzAstra FÚ
alternatorÚC18NZÚ
0120488234g     €q@Ú3zhttps://a.pl/3zFiltr oleju SCANIA R500ÚSCANIAÚR500Úfiltrg      ^@)	r   r   r   r   r   r   r   r   r   )r   r   Úbuild_from_offers)ÚidxÚofferss     ú:/var/www/html/agent.samochodowy/tests/test_orchestrator.pyÚ_build_test_indexr-      s™   € Ü
�zÓ
"€CäØ 9Ð2BØ7Ø °'ØØ" JÐ/Øô	
ô 	Ø 6Ð/@Ø<Ø 	°LØØ$�~Øô	
ô 	Ø 9Ð2BØ+Ø &°7ØØô	
ð#€Fð2 ×Ñ˜&Ô!Ø€Jó    c                  ó   — t        dd¬«      S )NTr   )Údry_runÚdb_pathr   © r.   r,   Ú	_settingsr3   ,   s   € Ü˜D¨*Ô5Ð5r.   c                   ó   — e Zd Zd„ Zd„ Zy)ÚTestPipelineIntegrationc                 ó¬  — t        «       }t        |dz  «      |_        t        d«      }t	        «       }t        |«      }t        ||||«      }|j                  t        j                  «      5  |j                  «       }ddd«       j                  }	d}
|	|
k(  }|s­t        j                  d|fd|	|
f«      dt        j                  «       v st        j                   |«      rt        j"                  |«      ndt        j"                  |	«      t        j"                  |
«      dœz  }d	d
|iz  }t%        t        j&                  |«      «      ‚dx}	x}}
|j(                  }	d}
|	|
k\  }|s­t        j                  d|fd|	|
f«      dt        j                  «       v st        j                   |«      rt        j"                  |«      ndt        j"                  |	«      t        j"                  |
«      dœz  }d	d
|iz  }t%        t        j&                  |«      «      ‚dx}	x}}
|j*                  |j,                  z   |j.                  z   }d}||k\  }	|	s™t        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}	}|j0                  }	d}
|	|
k(  }|s­t        j                  d|fd|	|
f«      dt        j                  «       v st        j                   |«      rt        j"                  |«      ndt        j"                  |	«      t        j"                  |
«      dœz  }d	d
|iz  }t%        t        j&                  |«      «      ‚dx}	x}}
|j3                  «        |j3                  «        y# 1 sw Y   �ŒOxY w)zGRun full pipeline on sample posts with in-memory index and dry-run CRM.ú
catalog.dbúdata/samples/posts.jsonNé   ©ú==)z3%(py2)s
{%(py2)s = %(py0)s.total_posts
} == %(py5)sÚstats©Úpy0Úpy2Úpy5úassert %(py7)sÚpy7é   )ú>=)z9%(py2)s
{%(py2)s = %(py0)s.skipped_prefilter
} >= %(py5)sé   )z%(py0)s >= %(py3)sÚleads_created)r>   Úpy3zassert %(py5)sr@   r   )z.%(py2)s
{%(py2)s = %(py0)s.errors
} == %(py5)s)r3   Ústrr1   r   r-   r   r	   Úat_levelÚloggingÚDEBUGÚrunÚtotal_postsÚ
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanationÚskipped_prefilterÚmatchedÚreviewÚno_matchÚerrorsÚclose)ÚselfÚcaplogÚtmp_pathÚsettingsÚsourceÚindexÚdgredÚpipeliner<   Ú@py_assert1Ú@py_assert4Ú@py_assert3Ú@py_format6Ú@py_format8rF   Ú@py_assert2Ú@py_format4s                    r,   Ú$test_full_pipeline_with_sample_postsz<TestPipelineIntegration.test_full_pipeline_with_sample_posts1   sW  € ä“;ˆÜ˜x¨,Ñ6Ó7ˆÔÜÐ4Ó5ˆÜ!Ó#ˆÜ˜HÓ%ˆä˜H f¨e°UÓ;ˆà�_‰_œWŸ]™]Ó+ñ 	#Ø—L‘L“NˆE÷	#ð × Ñ Ð& BÐ&Ð  BÑ&×&×&Õ&Ð  B×&×&×&×&×&Ñ&ˆu×&×&Ó&ˆu×&×&Ô&Ð ×&×&Ò& B×&×&×&×&×&×&Ó&ð ×&Ñ&Ð+¨!Ð+Ð&¨!Ñ+×+×+Õ+Ð&¨!×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð&×+×+Ò+¨!×+×+×+×+×+×+Ó+ð Ÿ™¨¯©Ñ4°u·~±~ÑEˆØ !Ð!ˆ} Ñ!×!×!Õ!ˆ} ×!×!×!×!×!Ñ!ˆ}×!×!Ó!ˆ}×!×!Ô! ×!×!×!×!×!×!Ñ!ð �|‰|Ð ˜qÐ ˆ|˜qÑ × × Õ ˆ|˜q× × × × × Ñ ˆu× × Ó ˆu× × Ô ˆ|× × Ò ˜q× × × × × × Ó à�‰ŒØ�‰�÷#	#ñ 	#ús   Á+O	Ï	Oc                 óô  — t        «       }t        |dz  «      |_        t        d«      }t	        «       }t        |«      }t        ||||«      }|j                  «       }|j                  }	d}
|	|
k(  }|s­t        j                  d|fd|	|
f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |	«      t        j                  |
«      dœz  }dd	|iz  }t        t        j                   |«      «      ‚d
x}	x}}
t        d«      }||_        |j                  «       }|j                  }	|j$                  }|	|k(  }|sît        j                  d|fd|	|f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |	«      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}	x}}|j'                  «        |j'                  «        y
)z<Running the same posts twice should mark them as duplicates.r7   r8   r   r:   )z2%(py2)s
{%(py2)s = %(py0)s.duplicates
} == %(py5)sÚstats1r=   rA   rB   N)zS%(py2)s
{%(py2)s = %(py0)s.duplicates
} == %(py6)s
{%(py6)s = %(py4)s.total_posts
}Ústats2)r>   r?   Úpy4Úpy6zassert %(py8)sÚpy8)r3   rH   r1   r   r-   r   r	   rL   Ú
duplicatesrN   rO   rP   rQ   rR   rS   rT   rU   r`   rM   r[   )r\   r]   r^   r_   r`   ra   rb   rc   rm   rd   re   rf   rg   rh   Úsource2rn   Ú@py_assert5Ú@py_format7Ú@py_format9s                      r,   Útest_dedup_on_second_runz0TestPipelineIntegration.test_dedup_on_second_runN   s’  € ä“;ˆÜ˜x¨,Ñ6Ó7ˆÔÜÐ4Ó5ˆÜ!Ó#ˆÜ˜HÓ%ˆä˜H f¨e°UÓ;ˆð —‘“ˆØ× Ñ Ð% AÐ%Ð  AÑ%×%×%Õ%Ð  A×%×%×%×%×%Ñ%ˆv×%×%Ó%ˆv×%×%Ô%Ð ×%×%Ò% A×%×%×%×%×%×%Ó%ô Ð5Ó6ˆØ!ˆŒØ—‘“ˆØ× Ñ Ð6 F×$6Ñ$6Ð6Ð Ð$6Ñ6×6×6Õ6Ð Ð$6×6×6×6×6×6Ñ6ˆv×6×6Ó6ˆv×6×6Ô6Ð ×6×6×6×6×6Ð6 F×6×6Ó6 F×6×6Ô6Ð$6×6×6×6×6×6×6Ó6à�‰ŒØ�‰�r.   N)Ú__name__Ú
__module__Ú__qualname__rk   rw   r2   r.   r,   r5   r5   0   s   „ òó:r.   r5   )Ú__doc__ÚbuiltinsrP   Ú_pytest.assertion.rewriteÚ	assertionÚrewriterN   rJ   Úagent_samochodowy.configr   Úagent_samochodowy.dgred.clientr   Ú%agent_samochodowy.ingestor.csv_sourcer   Úagent_samochodowy.matcher.indexr   Úagent_samochodowy.modelsr   Úagent_samochodowy.orchestratorr	   r-   r3   r5   r2   r.   r,   ú<module>r†      sC   ðÙ Vç  „ ƒå -Ý 6Ý ;Ý 8Ý *Ý 3ð˜<ó ð>6�8ó 6÷3ò 3r.   