
    6j                         d dl Zd dlmc mZ d dlmZ d dl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  G d d          Zdefd	Zd
 Zd ZdS )    N)Path)
TestClientBox)appc                       e Zd Zd ZdS )FakeDetectorc                 ,    t          dddddd          gS )N   <   g      ?fake_sensitiver   )selfframes     2/home/wildlama/intimate-blur-app/tests/test_api.py
detect_bgrzFakeDetector.detect_bgr   s    BBC)9::;;    N)__name__
__module____qualname__r    r   r   r	   r	      s#        < < < < <r   r	   pathc                     t          j        dt           j                  }d|ddddf<   t          j        t          |           |           d S )N)d   r      )dtype   r   r   )npzerosuint8cv2imwritestr)r   imgs     r   make_sampler$      sL    
(=
1
1
1CC2r"uKD		3r   c                 T   |                     t          dt                                 | dz  }t          |           t	          t
                    }|                    d          5 }|                    ddd|dfiddd	
          }d d d            n# 1 swxY w Y   |j        }d}||k    }|st          j
        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }	t          j        |j                  dz   d|	iz  }
t#          t          j        |
                    d x}x}}|                                }|d         }d}||u }|slt          j
        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t#          t          j        |                    d x}x}}|d         }|j        }d} ||          }|ssdt          j        |          t          j        |          t          j        |          t          j        |          dz  }
t#          t          j        |
                    d x}x}x}}d S )N	_detector
sample.pngrbz/api/processfile	image/png210)blur_strengthmargin)filesdata   ==z3%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py5)srespy0py2py5
>assert %(py7)spy7okT)is)z%(py1)s is %(py4)spy1py4assert %(py6)spy6download_urlz
/download/zLassert %(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.startswith
}(%(py5)s)
}r?   py3r9   r;   )setattrmain_modr	   r$   r   r   openpoststatus_code
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_saferepr_format_assertmsgtextAssertionError_format_explanationjson
startswith)tmp_pathmonkeypatchsrcclientfr5   @py_assert1@py_assert4@py_assert3@py_format6@py_format8r0   @py_assert0@py_assert2@py_format5@py_format7@py_assert6s                    r   test_api_process_image_legacyrf      sG   +|~~>>>
\
!C__F	$ G1kk.,;9W0Xqu  BE  `F  `Fk  G  GG G G G G G G G G G G G G G G?+c+?c!+++++++++?c++++++++++++3+++++3++++++?++++c++++++++38++++++++++++++++++++++++88::D::::8*8<8**<888888888888*8888<888888888888888888888888888888s   &!BBBc                 
   |                     t          dt                                 | dz  }t          |           t	          t
                    }|                    d          5 }|                    ddd|dfi          }d d d            n# 1 swxY w Y   |j        }d}||k    }|st          j
        d	|fd
||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }	t          j        |j                  dz   d|	iz  }
t#          t          j        |
                    d x}x}}|                                d         }|                    d|dddd          }|j        }d}||k    }|st          j
        d	|fd
||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }	t          j        |j                  dz   d|	iz  }
t#          t          j        |
                    d x}x}}|                                d         }|j        }d} ||          }|ssdt          j        |          t          j        |          t          j        |          t          j        |          dz  }
t#          t          j        |
                    d x}x}x}}|                                d         d         }d}||k    }|slt          j
        d	|fd||f          t          j        |          t          j        |          dz  }d d!|iz  }t#          t          j        |                    d x}x}}|                    d"|ddd#d$          }|j        }d}||k    }|st          j
        d	|fd
||f          d%t          j                    v st          j        |          rt          j        |          nd%t          j        |          t          j        |          dz  }	t          j        |j                  dz   d|	iz  }
t#          t          j        |
                    d x}x}}|                                d&         }|j        }d'} ||          }|ssdt          j        |          t          j        |          t          j        |          t          j        |          dz  }
t#          t          j        |
                    d x}x}x}}d S )(Nr&   r'   r(   z/api/uploadr)   r*   )r/   r1   r2   r4   uploadr6   r:   r;   file_idz/api/preview31z0.1r,   )ri   r-   r.   frame_index)r0   previewpreview_urlz_preview.pngzJassert %(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.endswith
}(%(py5)s)
}rD   meta
detections   )z%(py1)s == %(py4)sr>   rA   rB   z/api/render5)ri   r-   r.   detect_everyrenderrC   z_blurred.png)rF   rG   r	   r$   r   r   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   endswith)rW   rX   rY   rZ   r[   rh   r\   r]   r^   r_   r`   ri   rl   ra   rb   re   rc   rd   rs   s                      r   %test_upload_preview_render_image_flowru   $   s6   +|~~>>>
\
!C__F	$ \1]6L![;Y2Z[[\ \ \ \ \ \ \ \ \ \ \ \ \ \ \11$1111111111111111111116111116111111111111111111fk111111111111111111111111kkmmI&Gkk.7UYej{~//k  A  AG3#3#%333333333#33333333333373333373333333333#33333333w|333333333333333333333333<<>>-(A(1A.A11.AAAAAAAA(AAAA1AAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAA<<>>&!,/414/14444444444/144444/44441444444444444444444444444444[[SWchz}-~-~[F11$1111111111111111111116111116111111111111111111fk111111111111111111111111;;==(A(1A.A11.AAAAAAAA(AAAA1AAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs   &BBB)builtinsrM   _pytest.assertion.rewrite	assertionrewriterK   pathlibr   r    numpyr   fastapi.testclientr   app.blur_enginer   app.mainr   mainrG   r	   r$   rf   ru   r   r   r   <module>r      s                        



     ) ) ) ) ) )                  < < < < < < < <
 d        
9 
9 
9B B B B Br   