
    j                         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mZmZ d dlmZmZmZ d dlmZ d Zd Zd	 Zd
 Zd Zd ZdS )    N)create_content_brief)create_script_draft)LocalPreviewPlanbuild_local_preview_planvalidate_local_preview_plan)RenderManifestRenderSettingsbuild_render_manifest)create_shot_planc                  ~    t          dddd          } t          |           }t          t          |                    S )Nai_life_systemsAI weekly review routinez4I use AI tools but still lose control of priorities.z>a 10-minute Sunday review that keeps AI as assistant, not boss)	pillar_idtopicaudience_problempayoff)r   r   r
   r   )briefscripts     R/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/tests/test_local_preview.py	_manifestr      sH     #(OO	  E !''F !1&!9!9:::    c                     t                      } t          |           }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        }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        }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        }t+          |          }| j        }	t+          |	          }
||
k    }|st          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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}x}x}	}
|j        d         }|j        }d }||k    }|st          j        d|fd!||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d}||k    }|st          j        d|fd%||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d&}||k    }|st          j        d|fd'||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d(}||k    }|st          j        d|fd)||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d*}||k    }|st          j        d|fd+||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d,}||k    }|st          j        d|fd-||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d         }|j        }d.}||k    }|st          j        d|fd/||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d0         }|j        }d1}||k    }|st          j        d|fd%||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}|j        d0         }|j        }d2}||k    }|st          j        d|fd'||f          t          j        |          t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j
        |                    d x}x}x}}d S )3Nz5assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}
isinstanceplanr   )py0py1py2py4z(ai_life_systems-ai-weekly-review-routine==)z1%(py2)s
{%(py2)s = %(py0)s.script_id
} == %(py5)sr   r   py5assert %(py7)spy7r   )z-%(py2)s
{%(py2)s = %(py0)s.title
} == %(py5)si  )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)sz6data/previews/ai_life_systems-ai-weekly-review-routine)z2%(py2)s
{%(py2)s = %(py0)s.output_dir
} == %(py5)s )z4%(py2)s
{%(py2)s = %(py0)s.side_effects
} == %(py5)s)z6%(py2)s
{%(py2)s = %(py0)s.external_calls
} == %(py5)s)z%(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.frames
})
} == %(py12)s
{%(py12)s = %(py7)s(%(py10)s
{%(py10)s = %(py8)s.timeline
})
}lenmanifest)r   r   py3r"   r$   py8py10py12zassert %(py14)spy14r   zframe-01-first_frame_hook)z0%(py3)s
{%(py3)s = %(py1)s.frame_id
} == %(py6)s)r   r)   py6zassert %(py8)sr*   )z0%(py3)s
{%(py3)s = %(py1)s.start_ms
} == %(py6)si  )z3%(py3)s
{%(py3)s = %(py1)s.duration_ms
} == %(py6)sfirst_frame_hook)z5%(py3)s
{%(py3)s = %(py1)s.scene_purpose
} == %(py6)sz4If AI runs your week, you have already lost control.)z4%(py3)s
{%(py3)s = %(py1)s.caption_text
} == %(py6)skinetic_text_overlay)z2%(py3)s
{%(py3)s = %(py1)s.asset_mode
} == %(py6)szTdata/previews/ai_life_systems-ai-weekly-review-routine/frame-01-first_frame_hook.png)z>%(py3)s
{%(py3)s = %(py1)s.placeholder_image_path
} == %(py6)si0u  i  )r   r   r   r   @py_builtinslocals
@pytest_ar_should_repr_global_name	_safereprAssertionError_format_explanation	script_id_call_reprcomparetitlewidthheightfps
output_dirside_effectsexternal_callsframesr'   timelineframe_idstart_msduration_msscene_purposecaption_text
asset_modeplaceholder_image_path)r(   r   @py_assert3@py_format5@py_assert1@py_assert4@py_format6@py_format8@py_assert2@py_assert9@py_assert11@py_assert6@py_format13@py_format15@py_assert0@py_assert5@py_format7@py_format9s                     r   Atest_build_local_preview_plan_creates_side_effect_free_frame_planr[      sj   {{H#H--Dd,---------------:-----:-------------d-----d-------------,-----,------------------------>GGG>GGGGGGGGGGG>GGGGGGGGGGGGG4GGGGG4GGGGGG>GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG: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34333334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:::44:;#;#;#44;#8r8r>8r448r?VVV?VVVVVVVVVVV?VVVVVVVVVVVVV4VVVVV4VVVVVV?VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV""""""""""""""""""""""""4"""""4"""""""""""""""""""""""""""""""""""""$"$"$$$$$$$$$$"$$$$$$$$$$$$4$$$$$4$$$$$$$$$$"$$$$$$$$$$$$$$$$$$$$$$$$$$${53{58#45s#455555555555555555555555555535555535555555555555t55555t555555{555555555555555s55555s55555555555558555558555555#4555555555555555555555555555555555555;q>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;q>'>"'a'"a''''''''''"a'''''>''''"''''a''''''''''''''''''''''''''''';q>->%--%----------%----->----%---------------------------------;q>=>'=+=='+==========='+======>===='====+==============================;q>`>&`*``&*```````````&*``````>````&````*``````````````````````````````;q>>>$>(>>$(>>>>>>>>>>>$(>>>>>>>>>>>$>>>>(>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;q> >0 ^0^       0^        1    	_                           ;r?,?#,u,#u,,,,,,,,,,#u,,,,,?,,,,#,,,,u,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;r?.?&.$.&$..........&$.....?....&....$...............................r   c                  V   t          t          t                                          } | 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}}| 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 )NTisz0%(py2)s
{%(py2)s = %(py0)s.is_valid
} is %(py5)sresultr!   r#   r$   r&   r   )z.%(py2)s
{%(py2)s = %(py0)s.errors
} == %(py5)s)r   r   r   is_validr4   r:   r2   r3   r5   r6   r7   r8   errors)r`   rM   rN   rK   rO   rP   s         r   5test_validate_local_preview_plan_accepts_default_planrc   5   s   ()A)++)N)NOOF?"d"?d""""""""""?d""""""""""""6"""""6""""""?""""d"""""""""""""""""""""""""""=B=B=B66=Br   c                  
   t                      } t          | j        | j        t	          dd          | j                  }t          j        t          d          5  t          |           d d d            d S # 1 swxY w Y   d S )N  8  )r<   r=   )r9   r;   settingsrC   z&render size must be vertical 1080x1920)match)
r   r   r9   r;   r	   rC   pytestraises
ValueErrorr   )r(   invalids     r   6test_build_local_preview_plan_rejects_invalid_manifestrm   <   s    {{H$nd4888"	  G 
z)Q	R	R	R * * )))* * * * * * * * * * * * * * * * * *s   A88A<?A<c                  (   t          t                                } t          | j        | j        ddd| j        | j        dd	  	        }t          |          }|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}|j        }||v }	|	st          j
        d|	fd||f          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}	}d}|j        }||v }	|	st          j
        d|	fd||f          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}	}d}|j        }||v }	|	st          j
        d|	fd||f          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}	}d}|j        }||v }	|	st          j
        d|	fd||f          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}	}d S )Nre   rf   r   )	write_png)ffmpeg	r9   r;   r<   r=   r>   r?   rB   r@   rA   Fr]   r_   r`   r!   r#   r$   zpreview size must be verticalinz.%(py1)s in %(py5)s
{%(py5)s = %(py3)s.errors
}r   r)   r"   zfps must be positivez'preview plan must not have side effectsz)preview plan must not call external tools)r   r   r   r9   r;   r?   rB   r   ra   r4   r:   r2   r3   r5   r6   r7   r8   rb   )
r   unsafer`   rM   rN   rK   rO   rP   rW   rQ   s
             r   Qtest_validate_local_preview_plan_rejects_side_effects_external_calls_and_bad_sizerw   I   s   #IKK00D.j?{#"
 
 
F )00F?#e#?e##########?e############6#####6######?####e###########################*;fm;*m;;;;;;;;;;*m;;;;;*;;;;;;;;;;;f;;;;;f;;;;;;m;;;;;;;;;;;;;;;;;;;;;;;;;;;!2V]2!]2222222222!]22222!22222222222V22222V222222]2222222222222222222222222224EE4EEEEEEEEEE4EEEEE4EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE6G&-G6-GGGGGGGGGG6-GGGGG6GGGGGGGGGGG&GGGGG&GGGGGG-GGGGGGGGGGGGGGGGGGGGGGGGGGGGGr   c                  8
   t          t                                } | j        d         } t          |          ddddddddd	  	        }t	          | j        | j        | j        | j        | j	        | j
        |f| j        dd          z   dd	  	        }t          |          }|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}
|j        }|
|v }|st          j        d|fd|
|f          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}}d}
|j        }|
|v }|st          j        d|fd|
|f          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}}d}
|j        }|
|v }|st          j        d|fd|
|f          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}}d}
|j        }|
|v }|st          j        d|fd|
|f          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}}d}
|j        }|
|v }|st          j        d|fd|
|f          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}}d S )Nr    i  )	rD   rG   rE   rF   rH   
label_textrI   motion_instructionrJ      r&   rq   Fr]   r_   r`   r!   r#   r$   zframe 1 frame_id is requiredrr   rt   ru   z$frame 1 duration_ms must be positivezfirst frame must start at 0msz frame 1 caption_text is requiredz*frame 1 placeholder_image_path is required)r   r   rB   typer   r9   r;   r<   r=   r>   r?   r   ra   r4   r:   r2   r3   r5   r6   r7   r8   rb   )r   first	bad_framerv   r`   rM   rN   rK   rO   rP   rW   rQ   s               r   Ltest_validate_local_preview_plan_rejects_bad_frame_timing_and_missing_fieldsr   `   s   #IKK00DKNEU!
 
 
I .jj{H?|dk!""o-
 
 
F )00F?#e#?e##########?e############6#####6######?####e###########################):V]:)]::::::::::)]:::::):::::::::::V:::::V::::::]:::::::::::::::::::::::::::1BV]B1]BBBBBBBBBB1]BBBBB1BBBBBBBBBBBVBBBBBV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BB*;fm;*m;;;;;;;;;;*m;;;;;*;;;;;;;;;;;f;;;;;f;;;;;;m;;;;;;;;;;;;;;;;;;;;;;;;;;;->>->>>>>>>>>>->>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>7H6=H7=HHHHHHHHHH7=HHHHH7HHHHHHHHHHH6HHHHH6HHHHHH=HHHHHHHHHHHHHHHHHHHHHHHHHHHHHr   )builtinsr2   _pytest.assertion.rewrite	assertionrewriter4   ri   autoshorts.content.briefr   autoshorts.content.script_draftr   "autoshorts.rendering.local_previewr   r   r   autoshorts.rendering.manifestr   r	   r
   autoshorts.rendering.shot_planr   r   r[   rc   rm   rw   r   r&   r   r   <module>r      s                 9 9 9 9 9 9 ? ? ? ? ? ?         
 ` _ _ _ _ _ _ _ _ _ ; ; ; ; ; ;; ; ;/ / /8  
* 
* 
*H H H.!I !I !I !I !Ir   