
    0p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mZ d Zd Zd Zd Zd	 Zd
 Zd ZdS )    Ncreate_content_brief)create_script_draft)ShotPlan	ShotScenecreate_shot_planvalidate_shot_planc                  F    t          dddd          } 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   )briefs    N/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/tests/test_shot_plan.py_scriptr      s2     #(OO	  E u%%%    c                  r   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}}d |j        D             }g 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 |j        D             }g d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }dd|iz  }
t          t          j
        |
                    d 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        }	| j        }|	|k    }|st          j        d|fd|	|f          t          j        |          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}	x}}|j        d$         }|j        }	| 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        }	| 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        }	| 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}}d(}|j        d         }|j        }|j        } |            }||v }	|	st          j        d)|	fd*||f          t          j        |          t          j        |          t          j        |          t          j        |          t          j        |          d+z  }d,d-|iz  }t          t          j
        |                    d x}x}	x}x}x}}d. |j        D             }t/          |          }|sd/d0t	          j                    v st          j        t.                    rt          j        t.                    nd0t          j        |          t          j        |          d1z  }t          t          j
        |                    d x}}d2 |j        D             }t/          |          }|sd/d0t	          j                    v st          j        t.                    rt          j        t.                    nd0t          j        |          t          j        |          d1z  }t          t          j
        |                    d 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)s#   )zB%(py2)s
{%(py2)s = %(py0)s.estimated_duration_seconds
} == %(py5)sc                     g | ]	}|j         
S  )purpose.0scenes     r   
<listcomp>zXtest_create_shot_plan_builds_five_retention_scenes_from_script_draft.<locals>.<listcomp>    s    333eEM333r   )first_frame_hookpattern_interruptcore_explanationscreen_or_card_visualcta)z%(py1)s == %(py4)s)r   r   zassert %(py6)spy6c                     g | ]	}|j         
S r%   )
asset_moder'   s     r   r*   zXtest_create_shot_plan_builds_five_retention_scenes_from_script_draft.<locals>.<listcomp>'   s    666E666r   )kinetic_text_overlaymechanism_animationscreen_recording_simulationr4   r3   r   )z5%(py3)s
{%(py3)s = %(py1)s.start_seconds
} == %(py6)s)r   py3r0   zassert %(py8)spy8)z3%(py3)s
{%(py3)s = %(py1)s.end_seconds
} == %(py6)s)zN%(py3)s
{%(py3)s = %(py1)s.caption_beat
} == %(py7)s
{%(py7)s = %(py5)s.hook
}script)r   r6   r    r"   zassert %(py9)spy9   )z4%(py3)s
{%(py3)s = %(py1)s.caption_beat
} == %(py6)s      zpattern interruptin)zm%(py1)s in %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py4)s.retention_goal
}.casefold
}()
})r   r   r0   r7   py10zassert %(py12)spy12c              3   $   K   | ]}|j         V  d S )N)labels_renderer_ownedr'   s     r   	<genexpr>zWtest_create_shot_plan_builds_five_retention_scenes_from_script_draft.<locals>.<genexpr>5   s%      DDuu*DDDDDDr   z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}all)r   r   r   c              3   (   K   | ]}d |j         vV  dS )zfake UI textN)visual_actionr'   s     r   rD   zWtest_create_shot_plan_builds_five_retention_scenes_from_script_draft.<locals>.<genexpr>6   s*      RRU~U%88RRRRRRr   )r   r   r   r   @py_builtinslocals
@pytest_ar_should_repr_global_name	_safereprAssertionError_format_explanation	script_id_call_reprcomparetitleestimated_duration_secondsscenesstart_secondsend_secondscaption_beathookretention_beatsretention_goalcasefoldrE   )r9   r   @py_assert3@py_format5@py_assert1@py_assert4@py_format6@py_format8@py_assert0@py_assert2@py_format7@py_assert5@py_format9@py_assert6@py_format10@py_assert7@py_assert9@py_format11@py_format13s                      r   Dtest_create_shot_plan_builds_five_retention_scenes_from_script_draftrl      s   YYFF##DdH%%%%%%%%%%%%%%%:%%%%%:%%%%%%%%%%%%%d%%%%%d%%%%%%%%%%%%%H%%%%%H%%%%%%%%%%%%%%%%%%%%%%%%>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*0b0*b0000000000*b0000000000004000004000000*0000b00000000000000000000000000033t{333  8 8 8 3 8        3 8     4   8                          76$+666  ; ; ; 6 ;        6 ;     7   ;                          ;q>,>',1,'1,,,,,,,,,,'1,,,,,>,,,,',,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;r?,?&,",&",,,,,,,,,,&",,,,,?,,,,&,,,,",,,,,,,,,,,,,,,,,,,,,,,,,,,,,;q>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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5;q>C>&C&*@*CC&*CCCCCCCCCCC&*CCCCCC>CCCC&CCCC*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC;q>C>&C&*@*CC&*CCCCCCCCCCC&*CCCCCC>CCCC&CCCC*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC;q>C>&C&*@*CC&*CCCCCCCCCCC&*CCCCCC>CCCC&CCCC*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCJ$+a.J."?J"?"HJ"H"H"J"JJ"JJJJJJJJJJJ"JJJJJJJJJJ.JJJJ"?JJJJ"HJJJJ"JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJDDDDDD3DDDDDDDDDDDDDDDD3DDDDD3DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDRRdkRRRR3RRRRRRRRRRRRRRRR3RRRRR3RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRr   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_validrJ   rP   rH   rI   rK   rL   rM   rN   errors)rq   r]   r^   r[   r_   r`   s         r   ,test_validate_shot_plan_accepts_default_planrt   9   s    0 ; ;<<F?"d"?d""""""""""?d""""""""""""6"""""6""""""?""""d"""""""""""""""""""""""""""=B=B=B66=Br   c                  t   t          ddddddddd		  	        } t          d
dd| f          }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 S )Nr+   r   r=   Hookz'Static slide with baked-in fake UI textstatic_slideshowzStop scrollF)	r&   rT   rU   voiceover_beatrG   r2   rV   rY   rC   r9   TitlerO   rQ   rR   rS   rn   rp   rq   r   r!   r"   z*static slideshow asset mode is not allowedr>   z.%(py1)s in %(py5)s
{%(py5)s = %(py3)s.errors
}r   r6   r    z*labels and captions must be renderer-ownedz$baked-in fake UI text is not allowedr   r   r	   rr   rJ   rP   rH   rI   rK   rL   rM   rN   rs   
r)   r   rq   r]   r^   r[   r_   r`   ra   rb   s
             r   ?test_validate_shot_plan_rejects_static_slideshow_and_baked_textr   @   s   "?%$#
 
 
E #$x	  D  %%F?#e#?e##########?e############6#####6######?####e###########################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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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BBr   c            
         t          dddddddd          } t          d	d
d| f          }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 S )Nr,   r<   r;   BeatzQuick motion cutr4   	Interrupt)r&   rT   rU   rx   rG   r2   rV   rY   r9   ry   r#   rz   Frn   rp   rq   r   r!   r"   z$first scene must be first_frame_hookr>   r{   r|   z6scene 1 end_seconds must be greater than start_secondsr}   r~   s
             r   Gtest_validate_shot_plan_rejects_bad_timing_and_missing_first_frame_hookr   [   s   #(("	 	 	E #%x	  D  %%F?#e#?e##########?e############6#####6######?####e###########################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CTv}TC}TTTTTTTTTTC}TTTTTCTTTTTTTTTTTvTTTTTvTTTTTT}TTTTTTTTTTTTTTTTTTTTTTTTTTTTTr   c                      t          t                      d          } t          j        t          d          5  t          |            d d d            d S # 1 swxY w Y   d S )N )rW   zhook is required)match)r   _script_to_briefpytestraises
ValueErrorr   )r9   s    r   2test_create_shot_plan_rejects_invalid_script_draftr   t   s     !1!3!3"===F	z);	<	<	< ! !   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   AAAc                  (    t          dddd          S r   r   r%   r   r   r   r   {   s%    #(OO	   r   )builtinsrH   _pytest.assertion.rewrite	assertionrewriterJ   r   autoshorts.content.briefr   autoshorts.content.script_draftr   autoshorts.rendering.shot_planr   r   r   r	   r   rl   rt   r   r   r   r   r%   r   r   <module>r      s                 9 9 9 9 9 9 ? ? ? ? ? ?           & & &S S SD  C C C6U U U2! ! !    r   