
    LAjb#                         d dl Zd dlmc mZ d dlmZmZmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d dlmZmZmZmZmZ d dlmZ dd
ededefdZd Zd Zd Zd Zd Z d Z!dS )    N)date	timedeltadatetime)
TestClient)Sessionselect)app)engine)ChildCoinTransactionCoinTransactionTypeScreenTimeDayAllowanceScreenTimeSession)admin_headersEmiliasessionnamereturnc                     |                      t          t                                        t          j        |k                                                        }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}}|S )Nis notz%(py0)s is not %(py3)schildpy0py3assert %(py5)spy5)execr   r   wherer   first
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation)r   r   r   @py_assert2@py_assert1@py_format4@py_format6s          F/home/agent/projects/FamilyDashboard/backend/tests/test_screen_time.py_childr/      s   LL,,UZ4-?@@AAGGIIE5555L    c            	      ,   t          t                    } t          ddd          }t          t                    5 }t          |          }|j        d d d            n# 1 swxY w Y   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
|                                           }|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}
}	t%          fd|                                d         D                       }|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}
||
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 !          }|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"         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}}
t          t                    5 }|                    t-          t.                                        t.          j        k    t.          j        |k                                                        }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}}t9          dddd(d)d)          |_        |                    |           |                                 d d d            n# 1 swxY w Y   |                     d d*d+|                                i!          }|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,         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)}
||
k    }|slt          j        d0|fd1||
f          t          j        |          t          j        |
          dz  }dd|iz  }t          t          j        |                    d x}x}}
|                                d"         d         }d}
||
k     }|slt          j        d2|fd3||
f          t          j        |          t          j        |
          dz  }dd|iz  }t          t          j        |                    d x}x}}
tA          |           }| !                    d4 d5|                                 |d6d$i7          }|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"         d         d6         }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 d|                                d6d !          }|j        }d8}	||	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 )9N        r   r   child_idr   r   r   /api/screen-time?date=   ==z3%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py5)sresponser   py2r   assert %(py7)spy7c              3   @   K   | ]}|d          d         k    |V  dS r   idN .0rowr5   s     r.   	<genexpr>zFtest_screen_time_defaults_start_stop_and_admin_lock.<locals>.<genexpr>   s7      ZZ3w<;MQY;Y;Y;Y;Y;Y;YZZr0   items	allowancetotal_minutes(   z%(py1)s == %(py4)spy1py4assert %(py6)spy6remaining_secondsi`	  /api/screen-time//startrun)r   idempotency_keyjsonitem
is_runningTisz%(py1)s is %(py4)sactive
   r   z/stopr   r   statusstoppedduration_seconds)>)z%(py1)s > %(py4)s)<)z%(py1)s < %(py4)s/api/admin/screen-time//lockedheadersrX     )"r   r	   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   get	isoformatstatus_codenextrX   postr   r   r   r    r5   dayr!   r   
started_ataddcommitr   patch)clienttodayr   r   r*   r+   r,   r-   r;   @py_assert4@py_assert3@py_format8rY   @py_assert0@py_format5@py_format7r^   ri   r5   s                     @r.   3test_screen_time_defaults_start_stop_and_admin_lockr}      s   __Fq"E	 Gw8                8484884zzF5??3D3DFFGGH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&ZZZZx}}w7ZZZZZD_-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#$,,$,,,,,,,,,,$,,,,,$,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,{{?x???uO`O`uzF{F{{||H&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&==??6"<08D80D88888888880D8888808888D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	 Gf%677==>O>X\d>dfwf{  @E  gE  F  F  G  G  M  M  O  O!!vT!!!!!!!!!!vT!!!!!!!!!!!!v!!!!!v!!!!!!T!!!!!!!!!!!!!!!!!!!!!!!!!$T1b"a;;F               {{>x>>>feooN_N_E`{aaH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&==??9%h/<9</9<<<<<<<<<</9<<<<</<<<<9<<<<<<<<<<<<<<<<<<<<<<<<<<<==??9%&89=A=9A==========9A=====9====A=============================??6"#67>$>7$>>>>>>>>>>7$>>>>>7>>>>$>>>>>>>>>>>>>>>>>>>>>>>>>>>F##G||ThTTARARTT^emuw{l||}}H&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&==??6";/9ATA9TAAAAAAAAAA9TAAAAA9AAAAT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{{?x???uO`O`u}F~F~{H&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&&&s$   AA"%A"EX22X69X6c            
      4   t          t                    } t          ddd          }t          t                    5 }t          |          }|j        }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}}|                    t!          |t"          j        d
dd                     |                                 d d d            n# 1 swxY w Y   |                     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  }dd|iz  }t          t          j        |                    d x}x}}
|	                                d         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"}||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          }|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$         }d%}||u }|slt          j        d&|fd'||f          t          j        |          t          j        |          dz  }dd |iz  }t          t          j        |                    d x}x}}t          t                    5 }|                    t3          t4                                        t4          j        |k    t4          j        |k                                                        }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}}|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) |                    t3          t                                         t           j        |k                                                         D             }tC          |          }d*}||k    }
|
st          j        d|
fd+||f          d,t          j
                    v st          j        tB                    rt          j        tB                    nd,d-t          j
                    v st          j        |          rt          j        |          nd-t          j        |          t          j        |          d.z  }d/d0|iz  }t          t          j        |                    d x}x}
}|d1         }|j"        }d2}| }||k    }
|
st          j        d|
fd3||f          t          j        |          t          j        |          t          j        |          d4z  }d5d6|iz  }t          t          j        |                    d x}x}x}
x}}d d d            d S # 1 swxY w Y   d S )7Nr2   r3   r4   r   r   r5   r   r   r      ztest budgetztest-screen-budget)r5   transaction_typeamountcommentrV   z/api/screen-time/exchangezswap-1)r5   r   rV   rW   r7   r8   r:   r;   r<   r>   r?   rY   rI   bonus_minutesr_   rL   rM   rP   rQ   rJ   2   same
idempotentTr[   r]   )z5%(py2)s
{%(py2)s = %(py0)s.bonus_minutes
} == %(py5)sc                 $    g | ]}d |j         v |S )Bildschirmzeitr   rE   txs     r.   
<listcomp>zVtest_screen_time_shop_exchange_spends_coins_and_adds_today_minutes.<locals>.<listcomp>N   sP      W  W  Wb  xH  LN  LV  xV  xVr  xV  xV  xVr0      z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)slentxsr   rN   r   rQ   assert %(py8)spy8r      )z/%(py3)s
{%(py3)s = %(py1)s.amount
} == -%(py6)srN   r   rQ   assert %(py9)spy9)#r   r	   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   rr   r   r   manualrs   ro   rl   rm   rX   r   r   r   r    r5   rp   r!   r   allr   r   )ru   rv   r   r   r5   r*   r+   r,   r-   r;   rw   rx   ry   rz   r{   r|   r   rI   r   @py_assert5@py_format9@py_assert7@py_format10s                          r.   Btest_screen_time_shop_exchange_spends_coins_and_adds_today_minutesr   8   s
   __Fq"E	 GWooeh!!XT!!!!!!!!!!XT!!!!!!!!!!!!X!!!!!X!!!!!!T!!!!!!!!!!!!!!!!!!!!!!!!!kk/8FYF`ij  uB  Th  i  i  i  j  j  jnn               {{6(\a\k\k\m\m  CK  >L  >L{  M  MH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&==??6";/@FBF@BFFFFFFFFFF@BFFFFF@FFFFBFFFFFFFFFFFFFFFFFFFFFFFFFFF==??6";/@FBF@BFFFFFFFFFF@BFFFFF@FFFFBFFFFFFFFFFFFFFFFFFFFFFFFFFF;;2hX]XgXgXiXi  G  :H  :H;  I  ID"s"s""""""""""s""""""""""""4"""""4""""""""""s"""""""""""""""""""""""""""99;;|$,,$,,,,,,,,,,$,,,,,$,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,	 #GLL(>!?!?!E!EF\FeiqFq  tJ  tN  RW  tW  "X  "X  Y  Y  _  _  a  a	 $$y$$$$$$$$$$y$$$$$$$$$$$$y$$$$$y$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&,",&",,,,,,,,,,&",,,,,,,,,,,,y,,,,,y,,,,,,&,,,,",,,,,,,,,,,,,,,,,,,,,,,,,,, W  WGLL)@)@)F)FG_ckGk)l)lmmqqss  W  W  W3xx1x1}x1ss33x11v"v}"""}""""""""""}"""""v""""}"""""""""""""""""""""""""""""""""""# # # # # # # # # # # # # # # # # #s%   C?EE	E	O(dddc                  
   t          t                    } t          |           }t          ddd          }t	          t
                    5 }t          |d          }|j        }d d d            n# 1 swxY w Y   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|                                 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}}|
                                d         }t)          |          }d}||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        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}}|t+          d          z   }|                     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  }	dd|	iz  }t          t          j        |                    d x}x}}|
                                d%         }|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"}||k    }|slt          j	        d|fd)||f          t          j        |          t          j        |          d*z  }d+d,|iz  }t          t          j        |                    d x}x}}d S ).Nr2   r3   r4   Valerier   r   r5   r   r   r   z/api/admin/screen-time?start=&days=7ri   r7   r8   r:   r;   r<   r>   r?   days   )z0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)sr   )r   r=   rO   r?   r   r   r   )r   re   rf   -   Test)base_minutesadjustment_minutesnotesrh   rY   rI   rJ   rK   rL   rM   rP   rQ   r   )r   r	   r   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   rk   rl   rm   rX   r   r   rt   )ru   ri   startr   r   r5   r*   r+   r,   r-   r;   rw   rx   ry   @py_assert6r   r   targetrY   rz   r{   r|   s                         r.   0test_admin_screen_time_week_range_and_adjustmentr   S   sD   __FF##Gq"E	 Gw	**8                8484884zzT%//:K:KTTT^ezffH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&}}v&,3&'',1,'1,,,,,,,,,,'1,,,,,,,,,,,,3,,,,,3,,,,,,&,,,,',,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,YA&&&&F||UhUUAQAQASASUU_f  A  Y[  fl  nm  nm|  n  nH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&==??6"D_-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W%//%//////////%/////%/////////////////////////////////s   	A--A14A1c                  
   t          t                    } t          ddd          }t          |           }t	          t
                    5 }t          |          }|j        }d d d            n# 1 swxY w Y   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
| 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  }	dd|	iz  }t          t          j        |                    d x}x}}|                     d| dd|                                i          }
|
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}}t	          t
                    5 }|j        }t+          t,                    } ||          }|j        } |            }g }||k    }|st          j	        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dt          j                    v st          j        t*                    rt          j        t*                    nddt          j                    v st          j        t,                    rt          j        t,                    nd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}x}}d d d            d S # 1 swxY w Y   d S )"Nr2   r3   r4   r   r   r5   r   r   r   re   rf   r   )r   r   r   rh   r7   r8   r:   r;   r<   r>   r?   rS   rT   r   rW   rj   )z%(py12)s
{%(py12)s = %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.exec
}(%(py6)s
{%(py6)s = %(py3)s(%(py4)s)
})
}.all
}()
} == %(py15)sr   r   r   )	r   r=   r   rO   rQ   r   py10py12py15zassert %(py17)spy17)r   r	   r   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   rt   rl   rm   ro   r   r   r   r   )ru   rv   ri   r   r   r5   r*   r+   r,   r-   r;   rw   rx   ry   r   r   @py_assert9@py_assert11@py_assert14@py_assert13@py_format16@py_format18s                         r.   *test_screen_time_empty_budget_blocks_startr   h   s   __Fq"EF##G	 Gw8                8484884||ThTTARARTT^e}~  RS  kl  mm  mm|  n  nH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&{{?x???vuO`O`Fa{bbH&3&3&&&&&&&&&&3&&&&&&&&&&&&8&&&&&8&&&&&&&&&&3&&&&&&&&&&&&&&&&&&&&&&&&&&&	 CG|BF#455B||566B6:B::<<BB<BBBBBBBBBB<BBBBBBBBBBBBwBBBBBwBBBBBB|BBBBBBBBBBBFBBBBBFBBBBBBBBBBBBB#4BBBBB#4BBBBBB5BBBB6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BBBBBBBBBBBBBC C C C C C C C C C C C C C C C C Cs%   	A,,A03A0GS77S;>S;c                     t          t                    } t          ddd          }t          t                    5 }t          |          }|j        d d d            n# 1 swxY w Y   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
|                                                                           }t%          fd|d         D                       }	t%          d |	d         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}||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}||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|
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  }d#d$|iz  }t          t          j        |                    d x}x}}|                                d%         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)}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}t          t                    5 }d* |                    t-          t.                                        t.          j        k                                                        D             }t7          |          }d}||k    }|st          j        d|fd+||f          d,t          j
                    v st          j        t6                    rt          j        t6                    nd,d-t          j
                    v st          j        |          rt          j        |          nd-t          j        |          t          j        |          d.z  }d/d0|iz  }t          t          j        |                    d x}x}}|d1         }|j        }d}||k    }|st          j        d|fd2||f          t          j        |          t          j        |          t          j        |          d3z  }d/d0|iz  }t          t          j        |                    d x}x}x}}d d d            n# 1 swxY w Y   |j        }d}||k    }|st          j        d|fd ||f          d4t          j
                    v st          j        |          rt          j        |          nd4t          j        |          t          j        |          d"z  }d#d$|iz  }t          t          j        |                    d x}x}}|                                d5         }d6}||u }|slt          j        d7|fd8||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|                     d9|
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  }d#d$|iz  }t          t          j        |                    d x}x}}|                                d%         d&         d'         }d1}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}t          t                    5 }d< |                    t-          t.                                        t.          j        k                                                        D             }d= |D             }dd>g}||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            n# 1 swxY w Y   |                     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  }d#d$|iz  }t          t          j        |                    d x}x}}|                                d%         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}}t;          |           }|                     dA|                                 dB|C                                          }t%          fdD|dE         D                       }|dF         }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 S )GNr2   r3   r4   r   r   r5   r   r   r   r6   c              3   @   K   | ]}|d          d         k    |V  dS rA   rC   rD   s     r.   rG   zQtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<genexpr>   s6      SSCL4F(4R4R4R4R4R4RSSr0   rH   c              3   2   K   | ]}|d          dk    |V  dS )slugzbuch-lesen-20NrC   )rE   rules     r.   rG   zQtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<genexpr>   s0      ZZ$v,/:Y:Y:Y:Y:Y:YZZr0   earning_rulesrequired_minutes   r8   rL   rM   rP   rQ   reward_minutesr_   coin_rewardr   z/api/screen-time/earnrB   z	read-once)r5   rule_idr   rV   rW   r7   r:   r!   r<   r>   r?   rY   rI   r   rJ   r   c                 $    g | ]}d |j         v |S zBildschirmzeit verdienenr   r   s     r.   r   zRtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<listcomp>   P      a  a  ab  xR  VX  V`  x`  x`r  x`  x`  x`r0   r   r   r   r   r   r   r   )z.%(py3)s
{%(py3)s = %(py1)s.amount
} == %(py6)sr   secondr   Tr[   r]   z/api/screen-time/earn/undo)r5   r   r   undoc                 $    g | ]}d |j         v |S r   r   r   s     r.   r   zRtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<listcomp>   r   r0   c                     g | ]	}|j         
S rC   )r   r   s     r.   r   zRtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<listcomp>   s    (((b	(((r0   z
read-againredoz$/api/admin/screen-time/report?start=r   r   c              3   @   K   | ]}|d          d         k    |V  dS rA   rC   rD   s     r.   rG   zQtest_screen_time_earn_rule_awards_once_and_report_counts_bonus.<locals>.<genexpr>   s6      VV3s7|D7IX7U7U37U7U7U7UVVr0   summaryearned_minutes)r   r	   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   rk   rl   rX   rn   ro   rm   r   r   r   r    r5   r   r   r   r   )ru   rv   r   r   r*   r+   r,   r-   overviewrY   r   rz   rx   r{   r|   r!   r   rw   ry   r   r   r   r   r   ri   reportr   r5   s                              @r.   >test_screen_time_earn_rule_awards_once_and_report_counts_bonusr   x   s$   __Fq"E	 Gw8                8484884zzF5??3D3DFFGGLLNNHSSSSx0SSSSSDZZo!6ZZZZZD"#)r)#r))))))))))#r)))))#))))r))))))))))))))))))))))))))) !'R'!R''''''''''!R'''''!''''R'''''''''''''''''''''''''''#!#!##########!#########!###########################KK/8X\]aXblql{l{l}l}  S^  7_  7_K  `  `E[[0HY]^bYcmrm|m|m~m~  T_  8`  8`[  a  aF########################5#####5#####################################::<<,_=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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	 "G a  aGLL)@)@)F)FG_ckGk)l)lmmqqss  a  a  a3xx1x1}x1ss33x11v!v}!!}!!!!!!!!!!}!!!!!v!!!!}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" " " " " " " " " " " " " " " $$$$$$$$$$$$$$$$$$$$$$$$6$$$$$6$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$;;==&.$.&$..........&$.....&....$...........................;;3x\`ae\fpupp  qB  qB  ;C  ;C;  D  DD"s"s""""""""""s""""""""""""4"""""4""""""""""s"""""""""""""""""""""""""""99;;v{+O<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	 4G a  aGLL)@)@)F)FG_ckGk)l)lmmqqss  a  a  a((C(((3QG3(G3333333333(G33333(3333G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 4 4 4 4 4 4 4 4 4 4 4 ;;.(W[\`Wakpkzkzk|k|  R^  6_  6_;  `  `D"s"s""""""""""s""""""""""""4"""""4""""""""""s"""""""""""""""""""""""""""99;;v{+O<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BBBBBBBBBBBBBBF##GZZYu?P?PYYYcjZkkpprrFVVVV&"3VVVVVG#$**$**********$*****$*********************************s7   AA"%A"H^77^;>^;C/n<<o o c                  
   t          t                    } t          |           }t          t                    5 }t          |d          }|j        }d d d            n# 1 swxY w Y   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|d	d
d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  }dd|iz  }t          t          j        |                    d 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         }||k    }|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"|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  }dd|iz  }t          t          j        |                    d 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 }||u }|slt          j        d(|fd)||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d S )*Nr   r   r   r5   r   r   r   z!/api/admin/screen-time/earn-rulesztest-klavier-20u   20 Minuten Klavier üben r   r_      Tc   )	r   titledescriptionr   r   r   r5   r^   
sort_orderrh      r8   r:   createdr<   r>   r?   r   r   rL   rM   rP   rQ   )z%(py1)s == %(py3)s)rN   r   z"/api/admin/screen-time/earn-rules/rB      )r   r5   r7   patchedr[   r]   )r   r	   r   r   r
   r/   rB   r"   r#   r$   r%   r&   r'   r(   r)   ro   rm   rX   rt   )ru   ri   r   r   r5   r*   r+   r,   r-   r   rw   rx   ry   r   rz   r{   r|   r   s                     r.   Gtest_admin_can_create_and_update_screen_time_earn_rule_with_coin_rewardr      s   __FF##G	 Gw	**8                8484884kk=w!+
V 
Vk 
 
G %#%#%%%%%%%%%%#%%%%%%%%%%%%7%%%%%7%%%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%<<>>&!D#!#!##########!#########!###########################
'x''''''''''x''''''''''''''''x'''''x'''''''''''''''''''''''''''llLT
LLV]tu  DH  eI  eIl  J  JG%#%#%%%%%%%%%%#%%%%%%%%%%%%7%%%%%7%%%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%<<>>&!-05A50A55555555550A5555505555A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5555s   AA #A )r   )"builtinsr$   _pytest.assertion.rewrite	assertionrewriter"   r   r   r   fastapi.testclientr   sqlmodelr   r   app.mainr	   app.db.sessionr
   
app.modelsr   r   r   r   r   tests.conftestr   strr/   r}   r   r   r   r   r   rC   r0   r.   <module>r      s_                 . . . . . . . . . . ) ) ) ) ) ) $ $ $ $ $ $ $ $       ! ! ! ! ! ! m m m m m m m m m m m m m m ( ( ( ( ( ( G 3 e    #' #' #'L# # #60 0 0*C C C (+ (+ (+V6 6 6 6 6r0   