
    gyjf
                     p    d dl Zd dlmc mZ d dlmZ d dlZd dl	m
Z
 d dlmZ d dlmZmZmZmZ d Zd ZdS )    N)Path)build_truetrace_final_voiceover),build_truetrace_weird_email_final_video_plan)MotionRenderResultbuild_motion_render_planrender_motion_previewvalidate_motion_render_planc                     t          d          }t          |          } fd|j        D             }|                                D ]}|                    d           t          | d|          }|j        }d |                                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}}|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}}|j        }|j        }d} ||          }|sdd	t          j                    v st          j        |          rt          j        |          nd	t          j        |          t          j        |          t          j        |          t          j        |          dz  }t          t          j        |                    d x}x}x}}|j        }|j        }d} ||          }|sdd	t          j                    v st          j        |          rt          j        |          nd	t          j        |          t          j        |          t          j        |          t          j        |          dz  }t          t          j        |                    d x}x}x}}|j        }|j        }d} ||          }|sdd	t          j                    v st          j        |          rt          j        |          nd	t          j        |          t          j        |          t          j        |          t          j        |          dz  }t          t          j        |                    d x}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}}|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}}t3          |          }|j        }d}||u }|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%truetrace-ai-automation-quiet-rot-38sc                 6    i | ]}|j         |j          d z  S )z.png)scene_id).0scenetmp_paths     T/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/tests/test_motion_renderer.py
<dictcomp>zQtest_build_motion_render_plan_maps_final_plan_to_frame_output.<locals>.<dictcomp>   s-    jjjuen3J3J3J(Jjjj    s
   fake image      ?)
output_dirpreview_scalebackground_pathsc                 4    i | ]\  }}|t          |          S  )str)r   r   paths      r   r   zQtest_build_motion_render_plan_maps_final_plan_to_frame_output.<locals>.<dictcomp>   s$    +o+o+oNHdHc$ii+o+o+or   ==)z8%(py2)s
{%(py2)s = %(py0)s.background_paths
} == %(py5)srender_planpy0py2py5assert %(py7)spy7i  )z-%(py2)s
{%(py2)s = %(py0)s.width
} == %(py5)si  )z.%(py2)s
{%(py2)s = %(py0)s.height
} == %(py5)s   )z+%(py2)s
{%(py2)s = %(py0)s.fps
} == %(py5)szmotion-preview.mp4zkassert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.output_path
}.endswith
}(%(py6)s)
})r    r!   py4py6py8framesziassert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.frame_dir
}.endswith
}(%(py6)s)
}z
frames.txtzkassert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.concat_path
}.endswith
}(%(py6)s)
}r   z4%(py2)s
{%(py2)s = %(py0)s.side_effects
} == %(py5)sz6%(py2)s
{%(py2)s = %(py0)s.external_calls
} == %(py5)sT)is)z0%(py2)s
{%(py2)s = %(py0)s.is_valid
} is %(py5)s
validation)r   r   scenesvalueswrite_bytesr   r   items
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationwidthheightfpsoutput_pathendswith	frame_dirconcat_pathside_effectsexternal_callsr	   is_valid)r   	voiceover
final_planr   r   r   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert5@py_assert7@py_format9r-   s   `              r   =test_build_motion_render_plan_maps_final_plan_to_frame_outputrN      s	   /0WXXI=iHHJjjjjXbXijjj '')) ( (''''*)	  K 'o+o+oVfVlVlVnVn+o+o+oo'+ooooooooooo'+ooooooooooooo;ooooo;oooooo'oooo+oooooooooooooooooooooooooooo########################;#####;#####################################$$$$$$$$$$$$$$$$$$$$$$$$;$$$$$;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$? b ?b          ?b            ;     ;      ?    b                           "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+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 3 )3(3))(333333333333333;33333;333333 3333)3333(3333333333333333333333333333"9"+9L9++L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9L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#)r)#r))))))))))#r))))))))))));)))));))))))#))))r)))))))))))))))))))))))))))%++%++++++++++%++++++++++++;+++++;++++++%+++++++++++++++++++++++++++++++,[99J&$&$&&&&&&&&&&$&&&&&&&&&&&&:&&&&&:&&&&&&&&&&$&&&&&&&&&&&&&&&&&&&&&&&&&&&&&r   c           	         t          d          }t          |          }t          || d          g fd}t          |d          }t	          |t
                    }|sd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	d
t          j                    v st          j	        t
                    rt          j
        t
                    nd
t          j
        |          dz  }t          t          j        |                    d }|j        }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
        |          t          j
        |	          dz  }dd|iz  }t          t          j        |                    d x}x}x}
}	d |j        D             }t!          |          }|sd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        }t%          |          }|j        }
 |
            }|sd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
        |          t          j
        |
          t          j
        |          dz  }t          t          j        |                    d x}x}x}
}sedddt          j                    v st          j	                  rt          j
                  ndiz  }t          t          j        |                    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         }||v }|slt          j        d%|fd&||f          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}}|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 ).Nr   r   )r   r   c                                         |            t          j                                      d           t	          j        | ddd          S )Ns   fake mp4r   ok )stdoutstderr)appendr   r=   r0   
subprocessCompletedProcess)commandcapture_outputtextcheckcallsr   s       r   fake_runnerzPtest_render_motion_preview_writes_frames_and_invokes_ffmpeg.<locals>.fake_runner/   sN    W[$%%11+>>>*7Ad2NNNNr      )runnermax_frames_per_scenez5assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}
isinstanceresultr   )r    py1r!   r&   
   r   )zQ%(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.frame_paths
})
} == %(py8)slen)r    rc   py3r"   r(   zassert %(py10)spy10c              3   X   K   | ]%}t          |                                          V  &d S )N)r   exists)r   r   s     r   	<genexpr>zNtest_render_motion_preview_writes_frames_and_invokes_ffmpeg.<locals>.<genexpr>8   s4      BBttDzz  ""BBBBBBr   z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}all)r    r!   r&   zassert %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.concat_path
})
}.exists
}()
}r   r   )r    rc   rf   r"   r$   py9zassert %(py0)sr    r\   r   ffmpeg)z%(py1)s == %(py4)s)rc   r&   zassert %(py6)sr'   z-f)in)z%(py1)s in %(py4)s)	write_pngwrite_concatcall_ffmpeg	write_mp4r*   r   r#   r$   )rm   r+   )r   r   r   r   ra   r   r4   r5   r2   r6   r7   r8   r9   frame_pathsre   r3   rk   r@   r   ri   rA   rB   )r   rD   rE   r]   rb   rH   @py_format5@py_assert2rG   rL   @py_assert6rM   @py_format11rF   @py_assert8@py_format10@py_format1@py_assert0@py_format7rI   rJ   r\   r   s                        @@r   ;test_render_motion_preview_writes_frames_and_invokes_ffmpegr}   )   s   /0WXXI=iHHJ*:(Z]^^^KEO O O O O O
 #;{YZ[[[Ff0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1111f11111f11111111111110111110111111111111111111111111!(3!""(b("b(((((((((("b((((((((((((3(((((3(((((((((((((v(((((v((((((!(((("((((b(((((((((((((((((((((((((((((BBv/ABBBB3BBBBBBBBBBBBBBBB3BBBBB3BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'14'((1(/1//1111111111111114111114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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11LLLLLLLLLLLL5LLLLL5LLLLLLLLLLLLLLLL8A;"(";("""""""""";(""""";""""("""""""""""""""""""""""""""58484848["[["[[[[[[[[[[["[[[[[[[[[[[[[6[[[[[6[[[[[[[[[["[[[[[[[[[[[[[[[[[[[[[[[[[[[[ /K/ K////////// K////////////6/////6////// ////K/////////////////////////////r   )builtinsr4   _pytest.assertion.rewrite	assertionrewriter2   pathlibr   rV   autoshorts.audio.voiceoverr   %autoshorts.rendering.final_video_planr   $autoshorts.rendering.motion_rendererr   r   r   r	   rN   r}   r   r   r   <module>r      s                            F F F F F F ^ ^ ^ ^ ^ ^           ' ' '60 0 0 0 0r   