
    f{j
                     ~    d dl Zd dlmc mZ d dlmZ d dlm	Z	  e	d          Z
d Zd Zd Zd Zd	 Zd
 Zd Zd ZdS )    N)	state_lib)load_bin_moduleepaper_displayc                  $    ddddddddd	d
didS )N	sbs_mjpeg	3200x1200z/dev/video0)mode
resolutiondevice_primary   
      640x240)idle_toggle_secondsrecording_refresh_secondsfull_refresh_everypreview_resolution	video_dirz/nonexistent-on-dev-machine)cameraepaperpaths r       HC:\Users\jvoigtlander\Desktop\BubbleCamCode\tests\test_epaper_display.pycfgr      s@    &kUbcc#$)+"$"+	
 
 <=	 	 	r   c                 V   t                               t                                }|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  }dd|iz  }t          t	          j        |                    d x}x}}|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  }dd|iz  }t          t	          j        |                    d x}x}}d S 
N   z   ==z,%(py2)s
{%(py2)s = %(py0)s.size
} == %(py5)simagepy0py2py5assert %(py7)spy71)z,%(py2)s
{%(py2)s = %(py0)s.mode
} == %(py5)s)r   build_data_imager   size
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr	   sim_envr$   @py_assert1@py_assert4@py_assert3@py_format6@py_format8s          r   ,test_build_data_image_has_correct_dimensionsr=      s   ++CEE22E:##:##########:############5#####5######:###############################:::55:r   c                    t                               t                                }d }||u}|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}}d S )N)is not)z%(py0)s is not %(py3)sr$   )r&   py3assert %(py5)sr(   )r   r,   r   r.   r/   r0   r1   r2   r3   r4   r5   )r7   r$   @py_assert2r8   @py_format4r;   s         r   ?test_build_data_image_reflects_not_recording_when_camera_absentrD      s     ++CEE22E5555r   c                 0   t          j        dd           t          j        ddddd           t                              t	                                }|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  }dd|iz  }t          t          j        |                    d x}x}}d S )Ncamera_primaryrunningsensorsgffffff5@gO@g@)temperature_chumidity_pctpressure_hpar   r!   r#   r$   r%   r)   r*   )r   write_stater   r,   r   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   s          r   4test_build_data_image_does_not_raise_with_full_staterM   !   s.   *I666)YdQUdjkkkk++CEE22E:##:##########:############5#####5######:#################################r   c                 V   t                               t                                }|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  }dd|iz  }t          t	          j        |                    d x}x}}|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  }dd|iz  }t          t	          j        |                    d x}x}}d S r   )r   build_camera_imager   r-   r.   r/   r0   r1   r2   r3   r4   r5   r	   r6   s          r   5test_build_camera_image_sim_falls_back_to_placeholderrP   (   s    --cee44E:##:##########:############5#####5######:###############################:::55:r   c           	         t           j        }t                      } ||          }d}||u }|s"t          j        d|fd||f          dt          j                    v st          j        t                     rt          j        t                     ndt          j        |          dt          j                    v st          j        t                    rt          j        t                    ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}x}x}}t          j        d	d
           t           j        }t                      } ||          }d}||u }|s"t          j        d|fd||f          dt          j                    v st          j        t                     rt          j        t                     ndt          j        |          dt          j                    v st          j        t                    rt          j        t                    ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}x}x}}d S )NFis)zn%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.recording_active
}(%(py5)s
{%(py5)s = %(py3)s()
})
} is %(py10)sr   r   r&   r'   r@   r(   r*   py10assert %(py12)spy12rF   rG   T)r   recording_activer   r.   r/   r0   r1   r2   r3   r4   r5   r   rL   )r7   r8   r9   @py_assert6@py_assert9@py_assert8@py_format11@py_format13s           r   )test_recording_active_tracks_camera_stater^   0   s   *:355:**511:U:1U::::::::::1U::::::::::::>:::::>::::::*:::::::::::3:::::3::::::5::::1::::U:::::::::::::::::::::::::::::::*I666*93559**5119T91T99999999991T999999999999>99999>999999*9999999999939999939999995999919999T999999999999999999999999999999999r   c           	         i fd}|                      t          j        d|           |                     dd           t          j        }t                      } ||          }d}||u }|s"t          j        d|fd||f          d	t          j	                    v st          j
        t                    rt          j        t                    nd	t          j        |          d
t          j	                    v st          j
        t
                    rt          j        t
                    nd
t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    dx}x}x}x}}d         }	|	|	                    d          dz            }
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}
|
|	v}|st          j        d|fd|
|	f          t          j        |
          dt          j	                    v st          j
        |	          rt          j        |	          nddz  }dd|iz  }t          t          j        |                    dx}
}dS )zRegression guard: previewing at the recording resolution once
    OOM-killed the Pi off the network (512MB, no swap). The preview must
    always capture at epaper.preview_resolution.c                 ,    | d<   t          d          )Ncmdzno camera on the dev machine)RuntimeError)ra   kwargscaptureds     r   fake_runzCtest_preview_grab_never_uses_recording_resolution.<locals>.fake_run<   s    9:::r   runBUBBLECAM_SIMF)raisingNrR   )zo%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.grab_camera_frame
}(%(py5)s
{%(py5)s = %(py3)s()
})
} is %(py10)sr   r   rT   rV   rW   ra   z-video_size   r   r!   )z%(py1)s == %(py4)s)py1py4zassert %(py6)spy6r   )not in)z%(py1)s not in %(py3)s)rj   r@   rA   r(   )setattrr   
subprocessdelenvgrab_camera_framer   r.   r/   r0   r1   r2   r3   r4   r5   index)monkeypatchre   r8   r9   rY   rZ   r[   r\   r]   ra   @py_assert0r:   rB   @py_format5@py_format7rC   r;   rd   s                    @r   1test_preview_grab_never_uses_recording_resolutionrw   6   sB    H; ; ; ; ; 15(CCC666+:CEE:++E22:d:2d::::::::::2d::::::::::::>:::::>::::::+:::::::::::C:::::C::::::E::::2::::d:::::::::::::::::::::::::::::::
5/Csyy''!+,9	9,	9999999999,	99999,9999	999999999999999999999999999!;c!!!!!!!!!!;c!!!!!;!!!!!!!!!!!c!!!!!c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!r   c                      t           j        } dddii} | |          }ddg}||k    }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |           t          j        |          t          j        |          t          j        |          d	z  }d
d|iz  }t          t          j	        |                    d x} x}x}x}}d S )Nr   r	   dual_node_mjpegcamera_leftcamera_rightr!   )zZ%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.camera_service_names
}(%(py4)s)
} == %(py9)sr   )r&   r'   rk   rl   py9zassert %(py11)spy11)
r   camera_service_namesr.   r/   r0   r1   r2   r3   r4   r5   )r8   r:   @py_assert5r[   @py_assert7@py_format10@py_format12s          r   #test_camera_service_names_dual_noder   I   s   . 6CT:U/V ../VWW \ W \        W \                     /    0W    X   \                               r   )builtinsr0   _pytest.assertion.rewrite	assertionrewriter.   	bubblecamr   conftestr   r   r   r=   rD   rM   rP   r^   rw   r   r   r   r   <module>r      s                        $ $ $ $ $ $ !122
 
 
    $ $ $  : : :" " "&    r   