
                             S r SSKJr  SSKJs  Jr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\R&                  5      rg)z%Unit tests for retention_util module.    )absolute_importN)_RetentionPeriodToString)DaysToSeconds)MonthsToSeconds)RetentionInDaysMatch)RetentionInMonthsMatch)RetentionInSeconds)RetentionInSecondsMatch)RetentionInYearsMatch)SECONDS_IN_DAY)SECONDS_IN_MONTH)SECONDS_IN_YEAR)YearsToSecondsc                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)TestRetentionUtil"   z,Unit tests for gsutil retention_util module.c                     [        S5      nU R                  US[        -  5        [        S5      nU R                  US[        -  5        g N      )r   assertEqualr   selfsecss     2platform/gsutil/gslib/tests/test_retention_util.pytestDaysToSeconds#TestRetentionUtil.testDaysToSeconds%   s@    DT1~-.DT1~-.    c                     [        S5      nU R                  US[        -  5        [        S5      nU R                  US[        -  5        g r   )r   r   r   r   s     r   testMonthsToSeconds%TestRetentionUtil.testMonthsToSeconds,   sB    1DT1//01DT1//0r   c                     [        S5      nU R                  US[        -  5        [        S5      nU R                  US[        -  5        g r   )r   r   r   r   s     r   testYearsToSeconds$TestRetentionUtil.testYearsToSeconds3   s@    !DT1./!DT1./r   c                     Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  S U5        g )N30s30number1s11second)r
   r   group)r   r   
secs_matchs      r   testRetentionInSecondsMatch-TestRetentionUtil.testRetentionInSecondsMatch:   su    D(.JT:++H56D(.JS***845D(.JT:&r   c                     Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  S U5        g )N30mr'   r(   1mr*   1month)r   r   r,   )r   monthsmonths_matchs      r   testRetentionInMonthsMatch,TestRetentionUtil.testRetentionInMonthsMatchG   su    F)&1LT<--h78F)&1LS,,,X67F)&1LT<(r   c                     Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  S U5        g )N30dr'   r(   1dr*   1day)r   r   r,   )r   days
days_matchs      r   testRetentionInDaysMatch*TestRetentionUtil.testRetentionInDaysMatchT   su    D%d+JT:++H56D%d+JS***845D%d+JT:&r   c                     Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  SUR                  S5      5        Sn[        U5      nU R                  S U5        g )N30yr'   r(   1yr*   1year)r   r   r,   )r   yearsyears_matchs      r   testRetentionInYearsMatch+TestRetentionUtil.testRetentionInYearsMatcha   su    E'.KT;,,X67E'.KS+++H56E'.KT;'r   c                    Sn[        U5      nU R                  [        U5        Sn[        U5      nU R                  [        U5        Sn[        U5      nU R                  [        U5        Sn[        U5      nU R                  SU5        g )NrB   r2   r:   r)   r   )r	   r   r   r   r   )	r   one_yearone_year_in_seconds	one_monthone_month_in_secondsone_dayone_day_in_seconds
one_secondone_second_in_secondss	            r   testRetentionInSeconds(TestRetentionUtil.testRetentionInSecondsn   s    H,X6_&9:I-i8%';<G+G4^%78J.z:Q-.r   c                 z   [        [        5      nU R                  US5        [        [        S-
  5      nU R                  US5        [        [        S-   5      nU R                  US5        [        [        5      nU R                  US5        [        [        S-
  5      nU R                  US5        [        [        S-   5      nU R                  US5        [        [        5      nU R                  US5        [        [        S-
  5      nU R                  US	5        [        [        S-   5      nU R                  US
5        g )NzDuration: 1 Day\(s\)r   zDuration: 86399 Second\(s\)z'Duration: 86401 Seconds \(~1 Day\(s\)\)zDuration: 1 Month\(s\)z*Duration: 2678399 Seconds \(~30 Day\(s\)\)z*Duration: 2678401 Seconds \(~31 Day\(s\)\)zDuration: 1 Year\(s\)z,Duration: 31557599 Seconds \(~365 Day\(s\)\)z,Duration: 31557601 Seconds \(~365 Day\(s\)\))r   r   assertRegexr   r   )r   retention_strs     r   testRetentionPeriodToString-TestRetentionUtil.testRetentionPeriodToString   s(   ,^<M]$;<,^a-?@M]$BC,^a-?@M]$NO,-=>M]$=>,-=-ABM]BD --=-ABM]BD -_=M]$<=,_q-@AM]DF -_q-@AM]DFr    N)__name__
__module____qualname____firstlineno____doc__r   r    r#   r.   r6   r>   rF   rQ   rV   __static_attributes__rX   r   r   r   r   "   s3    4/10')'(/"Fr   r   )r]   
__future__r   gslib.tests.testcaseteststestcasegslib.utils.retention_utilr   r   r   r   r   r	   r
   r   r   r   r   r   GsUtilUnitTestCaser   rX   r   r   <module>re      sM    , & ' ' ? 4 6 ; = 9 > < 5 7 6 5{F33 {Fr   