Ë
    �FBju)  ã                  ó  — d Z ddlmZ ddlZddlmc mZ ddl	Z	ddl
m
Z
mZ ddlmZ ddlZddlmZ ddlmZ dd„Z G d	„ d
«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zy)zHTests for AccountGuard: suspension, daily cap, threat detection, warmup.é    )ÚannotationsN)ÚdatetimeÚ	timedelta)Úpatch)ÚAccountGuard)ÚSettingsc                ó~   — t        ddt        | dz  «      dddddddd¬«      }|j                  |«       t        d	i |¤ŽS )
NÚtestTztest.dbÚshadowé   Ú útest@test.com)Údgred_api_keyÚdry_runÚdb_pathÚbilling_modeÚmax_daily_scansÚwarmup_untilÚsendgrid_api_keyÚnotify_email_toÚnotify_email_fromÚ
fb_cookiesÚfb_proxy_url© )ÚdictÚstrÚupdater   )Útmp_pathÚ	overridesÚdefaultss      ú;/var/www/html/agent.samochodowy/tests/test_account_guard.pyÚ	_settingsr"      sS   € ÜØØÜ�H˜yÑ(Ó)ØØØØØØ)ØØô€Hð ‡O�O�IÔÜÑ�hÑÐó    c                  ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)ÚTestSuspensionc                ó  — t        t        |«      «      }|j                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}x}x}}|j                  «        y )NF©Úis©zK%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.is_suspended
}()
} is %(py7)sÚguard©Úpy0Úpy2Úpy4Úpy7úassert %(py9)sÚpy9)r   r"   Úis_suspendedÚ
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanationÚclose©	Úselfr   r*   Ú@py_assert1Ú@py_assert3Ú@py_assert6Ú@py_assert5Ú@py_format8Ú@py_format10s	            r!   Útest_not_suspended_by_defaultz,TestSuspension.test_not_suspended_by_default&   s¡   € ÜœY xÓ0Ó1ˆØ×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                ó6  — t        t        |«      «      }|j                  d«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}x}x}}|j                  «        y )	Nztest reasonTr'   r)   r*   r+   r0   r1   )r   r"   Úsuspendr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   s	            r!   Útest_suspend_sets_flagz%TestSuspension.test_suspend_sets_flag+   s­   € ÜœY xÓ0Ó1ˆØ�‰�mÔ$Ø×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                óV  — t        t        |«      «      }|j                  d«       |j                  «        |j                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}x}x}}|j                  «        y )	Nr
   Fr'   r)   r*   r+   r0   r1   )r   r"   rF   Ú	unsuspendr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   s	            r!   Útest_unsuspend_clears_flagz)TestSuspension.test_unsuspend_clears_flag1   s·   € ÜœY xÓ0Ó1ˆØ�‰�fÔØ�‰ÔØ×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                óp  — t        |«      }t        |«      }|j                  d«       |j                  «        t        |«      }|j                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }	dd|	iz  }
t        t        j                  |
«      «      ‚d x}x}x}}|j                  «        y )	Nr
   Tr'   r)   Úg2r+   r0   r1   )r"   r   rF   r;   r2   r3   r4   r5   r6   r7   r8   r9   r:   )r=   r   ÚsÚg1rL   r>   r?   r@   rA   rB   rC   s              r!   Ú)test_suspension_persists_across_instancesz8TestSuspension.test_suspension_persists_across_instances8   s¿   € Ü�hÓˆÜ˜!‹_ˆØ
�
‰
�6ÔØ
�‰Œ
ä˜!‹_ˆØ�‰Ð(‰Ó Ð( DÐ(Ð  DÐ(×(×(Õ(Ð  D×(×(×(×(×(Ñ(ˆr×(×(Ó(ˆr×(×(Ô(ˆ×(×(Ò(Ð ×(×(Ò( D×(×(×(×(×(×(Õ(Ø
�‰�
r#   N)Ú__name__Ú
__module__Ú__qualname__rD   rG   rJ   rO   r   r#   r!   r%   r%   %   s   „ òò
òór#   r%   c                  ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTestDailyCapc                ó  — t        t        |d¬«      «      }|j                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd	|iz  }t        t        j                  |«      «      ‚d x}x}x}}|j                  «        y )
Né   ©r   Tr'   ©zN%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check_daily_cap
}()
} is %(py7)sr*   r+   r0   r1   )r   r"   Úcheck_daily_capr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   s	            r!   Útest_under_cap_returns_truez(TestDailyCap.test_under_cap_returns_trueH   s£   € ÜœY xÀÔCÓDˆØ×$Ñ$Ð.Ñ$Ó&Ð.¨$Ð.Ð&¨$Ð.×.×.Õ.Ð&¨$×.×.×.×.×.Ñ.ˆu×.×.Ó.ˆu×.×.Ô.Ð$×.×.Ò.Ð&×.×.Ò.¨$×.×.×.×.×.×.Õ.Ø�‰�r#   c                óX  — t        t        |d¬«      «      }t        d«      D ]  }|j                  «        Œ |j                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd	|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )
Né   rW   Fr'   rX   r*   r+   r0   r1   )r   r"   ÚrangeÚincrement_daily_countrY   r3   r4   r5   r6   r7   r8   r9   r:   r;   ©
r=   r   r*   Ú_r>   r?   r@   rA   rB   rC   s
             r!   Útest_at_cap_returns_falsez&TestDailyCap.test_at_cap_returns_falseM   sÂ   € ÜœY xÀÔCÓDˆÜ�q“ò 	*ˆAØ×'Ñ'Õ)ð	*à×$Ñ$Ð/Ñ$Ó&Ð/¨%Ð/Ð&¨%Ð/×/×/Õ/Ð&¨%×/×/×/×/×/Ñ/ˆu×/×/Ó/ˆu×/×/Ô/Ð$×/×/Ò/Ð&×/×/Ò/¨%×/×/×/×/×/×/Õ/Ø�‰�r#   c                óª  — t        t        |«      «      }|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                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}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                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}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                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}x}x}}|j                  «        y )
Né   ©ú==)zT%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.increment_daily_count
}()
} == %(py7)sr*   r+   r0   r1   é   )zJ%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.daily_count
}()
} == %(py7)s)r   r"   r^   r3   r4   r5   r6   r7   r8   r9   r:   Údaily_countr;   r<   s	            r!   Útest_increment_returns_countz)TestDailyCap.test_increment_returns_countT   s¯  € ÜœY xÓ0Ó1ˆØ×*Ñ*Ð1Ñ*Ó,Ð1°Ð1Ð,°Ñ1×1×1Õ1Ð,°×1×1×1×1×1Ñ1ˆu×1×1Ó1ˆu×1×1Ô1Ð*×1×1Ò1Ð,×1×1Ò1°×1×1×1×1×1×1Õ1Ø×*Ñ*Ð1Ñ*Ó,Ð1°Ð1Ð,°Ñ1×1×1Õ1Ð,°×1×1×1×1×1Ñ1ˆu×1×1Ó1ˆu×1×1Ô1Ð*×1×1Ò1Ð,×1×1Ò1°×1×1×1×1×1×1Õ1Ø× Ñ Ð'Ñ Ó"Ð' aÐ'Ð" aÑ'×'×'Õ'Ð" a×'×'×'×'×'Ñ'ˆu×'×'Ó'ˆu×'×'Ô'Ð ×'×'Ò'Ð"×'×'Ò' a×'×'×'×'×'×'Õ'Ø�‰�r#   N)rP   rQ   rR   rZ   ra   rh   r   r#   r!   rT   rT   G   s   „ òò
ór#   rT   c                  ó6   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚTestThreatDetectionc                óh  — t        t        |«      «      }ddiddig}|j                  d|«      }t        |«      }d}||k(  }|söt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  t        «      rt	        j                  t        «      nd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}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |
«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}
x}x}}|j                  «        y )NÚtextõ   Sprzedam turbinÄ™u   KupiÄ™ alternatorú
Test Grouprf   rd   ©z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sÚlenÚresult©r,   Úpy1Úpy3Úpy6úassert %(py8)sÚpy8Fr'   r)   r*   r+   r0   r1   ©r   r"   Úcheck_itemsrp   r3   r4   r5   r6   r7   r8   r9   r:   r2   r;   ©r=   r   r*   Úitemsrq   Ú@py_assert2rA   Ú@py_assert4Ú@py_format7Ú@py_format9r>   r?   r@   rB   rC   s                  r!   Útest_clean_items_pass_throughz1TestThreatDetection.test_clean_items_pass_througha   sU  € ÜœY xÓ0Ó1ˆØÐ-Ð.°Ð9LÐ0MÐNˆØ×"Ñ" <°Ó7ˆÜ�6‹{Ð˜aÐˆ{˜aÑ××Õˆ{˜a×××××ÑŒs××ÓŒs×××××Ò�6××Ó�6××Ôˆ{××Ò˜a××××××ÓØ×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                ój  — t        t        |«      «      }ddidddœg}|j                  d|«      }t        |«      }d}||k(  }|söt	        j
                  d|fd	||f«      d
t        j                  «       v st	        j                  t        «      rt	        j                  t        «      nd
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}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |
«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}
x}x}}|j                  «        y )Nrl   rm   úhttps://fb.com/groups/123zSome non-threat error©ÚurlÚerrorrn   rc   rd   ro   rp   rq   rr   rv   rw   Fr'   r)   r*   r+   r0   r1   rx   rz   s                  r!   Útest_error_items_filtered_outz1TestThreatDetection.test_error_items_filtered_outi   sZ  € ÜœY xÓ0Ó1ˆàÐ(Ð)Ø/Ð:QÑRð
ˆð ×"Ñ" <°Ó7ˆÜ�6‹{Ð˜aÐˆ{˜aÑ××Õˆ{˜a×××××ÑŒs××ÓŒs×××××Ò�6××Ó�6××Ôˆ{××Ò˜a××××××ÓØ×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                ód  — t        t        |«      «      }dddœg}|j                  d|«      }t        |«      }d}||k(  }|söt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  t        «      rt	        j                  t        «      nd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}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |
«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}
x}x}}|j                  «        y )Nr‚   z#PRIVATE GROUP and no data availablerƒ   rn   r   rd   ro   rp   rq   rr   rv   rw   Tr'   r)   r*   r+   r0   r1   rx   rz   s                  r!   Ú!test_private_group_error_suspendsz5TestThreatDetection.test_private_group_error_suspendst   sQ  € ÜœY xÓ0Ó1ˆà/Ð:_Ñ`ð
ˆð ×"Ñ" <°Ó7ˆÜ�6‹{Ð˜aÐˆ{˜aÑ××Õˆ{˜a×××××ÑŒs××ÓŒs×××××Ò�6××Ó�6××Ôˆ{××Ò˜a××××××ÓØ×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                ób  — t        t        |«      «      }ddig}|j                  d|«      }t        |«      }d}||k(  }|söt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  t        «      rt	        j                  t        «      nd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}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |
«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}
x}x}}|j                  «        y )Nr…   z:Facebook requires you to verify your identity (checkpoint)rn   r   rd   ro   rp   rq   rr   rv   rw   Tr'   r)   r*   r+   r0   r1   rx   rz   s                  r!   Útest_checkpoint_error_suspendsz2TestThreatDetection.test_checkpoint_error_suspends~   sM  € ÜœY xÓ0Ó1ˆØÐWÐXÐYˆØ×"Ñ" <°Ó7ˆÜ�6‹{Ð˜aÐˆ{˜aÑ××Õˆ{˜a×××××ÑŒs××ÓŒs×××××Ò�6××Ó�6××Ôˆ{××Ò˜a××××××ÓØ×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                óB  — t        t        |«      «      }ddig}|j                  d|«      }|j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }	d	d
|	iz  }
t        t	        j                  |
«      «      ‚d x}x}x}}|j                  «        y )Nr…   zCAPTCHA required to continuern   Tr'   r)   r*   r+   r0   r1   ©r   r"   ry   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   )r=   r   r*   r{   rq   r>   r?   r@   rA   rB   rC   s              r!   Útest_captcha_error_suspendsz/TestThreatDetection.test_captcha_error_suspends†   sÁ   € ÜœY xÓ0Ó1ˆØÐ9Ð:Ð;ˆØ×"Ñ" <°Ó7ˆØ×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                óB  — t        t        |«      «      }ddig}|j                  d|«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }d	d
|iz  }	t        t	        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Nr…   zYour account has been blockedrn   Tr'   r)   r*   r+   r0   r1   rŒ   ©
r=   r   r*   r{   r>   r?   r@   rA   rB   rC   s
             r!   Útest_blocked_error_suspendsz/TestThreatDetection.test_blocked_error_suspends�   s¿   € ÜœY xÓ0Ó1ˆØÐ:Ð;Ð<ˆØ×Ñ˜,¨Ô.Ø×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                óB  — t        t        |«      «      }ddig}|j                  d|«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }d	d
|iz  }	t        t	        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Nr…   zYou must log in to continuern   Tr'   r)   r*   r+   r0   r1   rŒ   r�   s
             r!   Útest_login_error_suspendsz-TestThreatDetection.test_login_error_suspends”   s¿   € ÜœY xÓ0Ó1ˆØÐ8Ð9Ð:ˆØ×Ñ˜,¨Ô.Ø×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   N)
rP   rQ   rR   r€   r†   rˆ   rŠ   r�   r�   r’   r   r#   r!   rj   rj   `   s%   „ òò	òòòòór#   rj   c                  ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTestRunFailuresc                ó6  — t        t        |«      «      }|j                  d«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }dd|iz  }t        t	        j                  |«      «      ‚d x}x}x}}|j                  «        y )	NÚFAILEDFr'   r)   r*   r+   r0   r1   ©r   r"   Úcheck_run_failurer2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   s	            r!   Útest_single_failure_no_suspendz.TestRunFailures.test_single_failure_no_suspend¡   s¯   € ÜœY xÓ0Ó1ˆØ×Ñ Ô)Ø×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                óz  — t        t        |«      «      }|j                  d«       |j                  d«       |j                  d«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }d	d
|iz  }t        t	        j                  |«      «      ‚d x}x}x}}|j                  «        y )Nr–   z	TIMED-OUTÚABORTEDTr'   r)   r*   r+   r0   r1   r—   r<   s	            r!   Ú(test_three_consecutive_failures_suspendsz8TestRunFailures.test_three_consecutive_failures_suspends§   sË   € ÜœY xÓ0Ó1ˆØ×Ñ Ô)Ø×Ñ Ô,Ø×Ñ 	Ô*Ø×!Ñ!Ð+Ñ!Ó#Ð+ tÐ+Ð# tÐ+×+×+Õ+Ð# t×+×+×+×+×+Ñ+ˆu×+×+Ó+ˆu×+×+Ô+Ð!×+×+Ò+Ð#×+×+Ò+ t×+×+×+×+×+×+Õ+Ø�‰�r#   c                óœ  — t        t        |«      «      }|j                  d«       |j                  d«       |j                  d«       |j                  d«       |j                  } |«       }d}||u }|sÁt	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }dd	|iz  }t        t	        j                  |«      «      ‚d x}x}x}}|j                  «        y )
Nr–   Ú	SUCCEEDEDFr'   r)   r*   r+   r0   r1   r—   r<   s	            r!   Útest_success_resets_counterz+TestRunFailures.test_success_resets_counter¯   sÙ   € ÜœY xÓ0Ó1ˆØ×Ñ Ô)Ø×Ñ Ô)Ø×Ñ Ô,Ø×Ñ Ô)Ø×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   N)rP   rQ   rR   r™   rœ   rŸ   r   r#   r!   r”   r”       s   „ òòór#   r”   c                  ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTestZeroPostsCyclesc                óv  — t        t        |«      «      }t        d«      D ]  }|j                  d«       Œ |j	                  «        |j
                  } |«       }d}||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd	|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )
Nr\   r   Fr'   r)   r*   r+   r0   r1   )r   r"   r]   Úrecord_group_resultÚend_of_cycle_checkr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r_   s
             r!   Útest_one_zero_cycle_no_suspendz2TestZeroPostsCycles.test_one_zero_cycle_no_suspend¾   sÎ   € ÜœY xÓ0Ó1ˆä�q“ò 	)ˆAØ×%Ñ% aÕ(ð	)à× Ñ Ô"Ø×!Ñ!Ð,Ñ!Ó#Ð, uÐ,Ð# uÐ,×,×,Õ,Ð# u×,×,×,×,×,Ñ,ˆu×,×,Ó,ˆu×,×,Ô,Ð!×,×,Ò,Ð#×,×,Ò, u×,×,×,×,×,×,Õ,Ø�‰�r#   c                ó  — t        |«      }t        |«      }t        d«      D ]  }|j                  d«       Œ |j	                  «        |j                  «        t        |«      }t        d«      D ]  }|j                  d«       Œ |j	                  «        |j                  } |«       }d}||u }	|	sÁt        j                  d|	fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }
dd	|
iz  }t        t        j                  |«      «      ‚d x}x}x}	}|j                  «        y )
Nr\   r   Tr'   r)   rL   r+   r0   r1   ©r"   r   r]   r£   r¤   r;   r2   r3   r4   r5   r6   r7   r8   r9   r:   )r=   r   rM   rN   r`   rL   r>   r?   r@   rA   rB   rC   s               r!   Útest_two_zero_cycles_suspendsz1TestZeroPostsCycles.test_two_zero_cycles_suspendsÇ   s  € Ü�hÓˆä˜!‹_ˆÜ�q“ò 	&ˆAØ×"Ñ" 1Õ%ð	&à
×ÑÔØ
�‰Œ
ô ˜!‹_ˆÜ�q“ò 	&ˆAØ×"Ñ" 1Õ%ð	&à
×ÑÔØ�‰Ð(‰Ó Ð( DÐ(Ð  DÐ(×(×(Õ(Ð  D×(×(×(×(×(Ñ(ˆr×(×(Ó(ˆr×(×(Ô(ˆ×(×(Ò(Ð ×(×(Ò( D×(×(×(×(×(×(Õ(Ø
�‰�
r#   c                ó¬  — t        |«      }t        |«      }t        d«      D ]  }|j                  d«       Œ |j	                  «        |j                  «        t        |«      }|j                  d«       |j                  d«       |j	                  «        |j                  «        t        |«      }t        d«      D ]  }|j                  d«       Œ |j	                  «        |j                  } |«       }d}	||	u }
|
sÁt        j                  d|
fd||	f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |	«      dœz  }d	d
|iz  }t        t        j                  |«      «      ‚d x}x}x}
}	|j                  «        y )Nr\   r   rV   Fr'   r)   Úg3r+   r0   r1   r§   )r=   r   rM   rN   r`   rL   rª   r>   r?   r@   rA   rB   rC   s                r!   Ú test_mixed_results_reset_counterz4TestZeroPostsCycles.test_mixed_results_reset_counterØ   sK  € Ü�hÓˆä˜!‹_ˆÜ�q“ò 	&ˆAØ×"Ñ" 1Õ%ð	&à
×ÑÔØ
�‰Œ
ô ˜!‹_ˆØ
×Ñ˜qÔ!Ø
×Ñ˜qÔ!Ø
×ÑÔØ
�‰Œ
ô ˜!‹_ˆÜ�q“ò 	&ˆAØ×"Ñ" 1Õ%ð	&à
×ÑÔØ�‰Ð)‰Ó Ð) EÐ)Ð  EÐ)×)×)Õ)Ð  E×)×)×)×)×)Ñ)ˆr×)×)Ó)ˆr×)×)Ô)ˆ×)×)Ò)Ð ×)×)Ò) E×)×)×)×)×)×)Õ)Ø
�‰�
r#   N)rP   rQ   rR   r¥   r¨   r«   r   r#   r!   r¡   r¡   ½   s   „ òòó"r#   r¡   c                  ó*   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zy)Ú
TestWarmupc                ó  — t        t        |d¬«      «      }|j                  } |«       }d }||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}x}x}}|j                  «        y )	Nr   ©r   r'   ©zQ%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.warmup_group_count
}()
} is %(py7)sr*   r+   r0   r1   )r   r"   Úwarmup_group_countr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   s	            r!   Útest_no_warmup_returns_nonez&TestWarmup.test_no_warmup_returns_noneö   s£   € ÜœY x¸bÔAÓBˆØ×'Ñ'Ð1Ñ'Ó)Ð1¨TÐ1Ð)¨TÐ1×1×1Õ1Ð)¨T×1×1×1×1×1Ñ1ˆu×1×1Ó1ˆu×1×1Ô1Ð'×1×1Ò1Ð)×1×1Ò1¨T×1×1×1×1×1×1Õ1Ø�‰�r#   c                óx  — t        j                  «       t        d¬«      z
  j                  d«      }t	        t        ||¬«      «      }|j                  } |«       }d }||u }|sÁt        j                  d|fd||f«      dt        j                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }d	d
|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Nrc   ©Údaysú%Y-%m-%dr¯   r'   r°   r*   r+   r0   r1   ©r   Únowr   Ústrftimer   r"   r±   r3   r4   r5   r6   r7   r8   r9   r:   r;   )
r=   r   Ú	yesterdayr*   r>   r?   r@   rA   rB   rC   s
             r!   Ú test_expired_warmup_returns_nonez+TestWarmup.test_expired_warmup_returns_noneû   sÃ   € Ü—\‘\“^¤i°QÔ&7Ñ7×AÑAÀ*ÓMˆ	ÜœY x¸iÔHÓIˆØ×'Ñ'Ð1Ñ'Ó)Ð1¨TÐ1Ð)¨TÐ1×1×1Õ1Ð)¨T×1×1×1×1×1Ñ1ˆu×1×1Ó1ˆu×1×1Ô1Ð'×1×1Ò1Ð)×1×1Ò1¨T×1×1×1×1×1×1Õ1Ø�‰�r#   c                óz  — t        j                  «       t        d¬«      z   j                  d«      }t	        t        ||¬«      «      }|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                  |«      t        j                  |«      d	œz  }d
d|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Né   r´   r¶   r¯   rc   rd   ©zQ%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.warmup_group_count
}()
} == %(py7)sr*   r+   r0   r1   r·   ©
r=   r   Úfuturer*   r>   r?   r@   rA   rB   rC   s
             r!   Útest_early_warmup_returns_1z&TestWarmup.test_early_warmup_returns_1  sÃ   € ä—,‘,“.¤9°"Ô#5Ñ5×?Ñ?À
ÓKˆÜœY x¸fÔEÓFˆØ×'Ñ'Ð.Ñ'Ó)Ð.¨QÐ.Ð)¨QÑ.×.×.Õ.Ð)¨Q×.×.×.×.×.Ñ.ˆu×.×.Ó.ˆu×.×.Ô.Ð'×.×.Ò.Ð)×.×.Ò.¨Q×.×.×.×.×.×.Õ.Ø�‰�r#   c                óz  — t        j                  «       t        d¬«      z   j                  d«      }t	        t        ||¬«      «      }|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                  |«      t        j                  |«      d	œz  }d
d|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Né	   r´   r¶   r¯   rf   rd   r¾   r*   r+   r0   r1   r·   r¿   s
             r!   Útest_mid_warmup_returns_2z$TestWarmup.test_mid_warmup_returns_2  óÃ   € ä—,‘,“.¤9°!Ô#4Ñ4×>Ñ>¸zÓJˆÜœY x¸fÔEÓFˆØ×'Ñ'Ð.Ñ'Ó)Ð.¨QÐ.Ð)¨QÑ.×.×.Õ.Ð)¨Q×.×.×.×.×.Ñ.ˆu×.×.Ó.ˆu×.×.Ô.Ð'×.×.Ò.Ð)×.×.Ò.¨Q×.×.×.×.×.×.Õ.Ø�‰�r#   c                óz  — t        j                  «       t        d¬«      z   j                  d«      }t	        t        ||¬«      «      }|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                  |«      t        j                  |«      d	œz  }d
d|iz  }	t        t        j                  |	«      «      ‚d x}x}x}}|j                  «        y )Nrf   r´   r¶   r¯   é   rd   r¾   r*   r+   r0   r1   r·   r¿   s
             r!   Útest_late_warmup_returns_4z%TestWarmup.test_late_warmup_returns_4  rÅ   r#   N)rP   rQ   rR   r²   r»   rÁ   rÄ   rÈ   r   r#   r!   r­   r­   õ   s   „ òò
òòór#   r­   c                  ó.   — e Zd Z ed«      d„ «       Zd„ Zy)ÚTestAlarmEmailzsendgrid.SendGridAPIClientc                ó–   — t        t        |dd¬«      «      }|j                  d«       |j                  d«       |j	                  «        y )NzSG.faker   )r   r   útest threat)r   r"   rF   Úassert_called_once_withr;   )r=   ÚMockSGr   r*   s       r!   Útest_alarm_sends_emailz%TestAlarmEmail.test_alarm_sends_email  sA   € äœYØØ&Ø+ô
ó ˆð
 	�‰�mÔ$Ø×&Ñ& yÔ1Ø�‰�r#   c                óH  — dd l }t        t        |«      «      }|j                  |j                  «      5  |j                  d«       d d d «       d„ |j                  D «       }t        |«      }|s•ddt        j                  «       v st        j                  t        «      rt        j                  t        «      ndt        j                  |«      t        j                  |«      dœz  }t        t        j                  |«      «      ‚d x}}|j                  «        y # 1 sw Y   ŒÓxY w)Nr   rÌ   c              3  ó8   K  — | ]  }d |j                   v –— Œ y­w)zCannot send alarmN)Úmessage)Ú.0Úrs     r!   ú	<genexpr>zJTestAlarmEmail.test_alarm_without_sendgrid_logs_warning.<locals>.<genexpr>,  s   è ø€ ÒL¸Ð&¨!¯)©)Ô3ÑLùs   ‚z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}Úany)r,   r-   r.   )Úloggingr   r"   Úat_levelÚWARNINGrF   ÚrecordsrÖ   r5   r6   r3   r7   r8   r9   r:   r;   )r=   r   Úcaplogr×   r*   r>   r?   Ú@py_format5s           r!   Ú(test_alarm_without_sendgrid_logs_warningz7TestAlarmEmail.test_alarm_without_sendgrid_logs_warning'  s±   € ÛÜœY xÓ0Ó1ˆØ�_‰_˜WŸ_™_Ó-ñ 	)Ø�M‰M˜-Ô(÷	)áL¸V¿^¹^ÔLÐLŒsÐLÓLÐLÑL×L×L×L×LÕLŒs×L×LÓLŒs×L×LÔLÐL×L×LÒLÐL×L×L×L×L×LÒLØ�‰�÷	)ð 	)ús   ´DÄD!N)rP   rQ   rR   r   rÏ   rÝ   r   r#   r!   rÊ   rÊ     s   „ Ù
Ð'Ó(ñó )ðór#   rÊ   )Úreturnr   )Ú__doc__Ú
__future__r   Úbuiltinsr5   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter3   Újsonr   r   Úunittest.mockr   ÚpytestÚagent_samochodowy.account_guardr   Úagent_samochodowy.configr   r"   r%   rT   rj   r”   r¡   r­   rÊ   r   r#   r!   ú<module>rê      sp   ðÙ Nå "ç  „ ƒß (Ý ã å 8Ý -ó ÷,ñ ÷Dñ ÷29ñ 9÷@ñ ÷:1ñ 1÷pñ ÷Lò r#   