imip-agent

tests/internal/qualifiers.py

1343:f184dc45aadf
2017-10-18 Paul Boddie Attempt to prevent erroneous store type configuration overriding.
     1 #!/usr/bin/env python     2      3 """     4 Test qualifiers for recurring events.     5      6 Copyright (C) 2014, 2015, 2017 Paul Boddie <paul@boddie.org.uk>     7      8 This program is free software; you can redistribute it and/or modify it under     9 the terms of the GNU General Public License as published by the Free Software    10 Foundation; either version 3 of the License, or (at your option) any later    11 version.    12     13 This program is distributed in the hope that it will be useful, but WITHOUT    14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    15 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more    16 details.    17     18 You should have received a copy of the GNU General Public License along with    19 this program.  If not, see <http://www.gnu.org/licenses/>.    20 """    21     22 from vRecurrence import *    23     24 def show(l):    25     for x in l:    26         print x    27     print    28     29 qualifiers = [    30     ("YEARLY", {"interval" : 1})    31     ]    32     33 l = order_qualifiers(qualifiers)    34 show(l)    35 dt = (1997, 11, 2)    36 l = get_datetime_structure(dt)    37 show(l)    38 l = combine_datetime_with_qualifiers(dt, qualifiers)    39 show(l)    40     41 s = get_selector(dt, qualifiers)    42 l = s.materialise(dt, (2003, 12, 24))    43 print len(l) == 7, 7, len(l)    44 print l[0] == (1997, 11, 2), (1997, 11, 2), l[0]    45 print l[-1] == (2003, 11, 2), (2003, 11, 2), l[-1]    46 print    47     48 qualifiers = [    49     ("YEARLY", {"interval" : 2}),    50     ("BYMONTH", {"values" : [1]}),    51     ("BYDAY", {"values" : [(6, None)]}),    52     ("BYHOUR", {"values" : [8, 9]}),    53     ("BYMINUTE", {"values" : [30]})    54     ]    55     56 l = order_qualifiers(qualifiers)    57 show(l)    58 dt = (1997, 1, 5, 8, 30, 0)    59 l = get_datetime_structure(dt)    60 show(l)    61 l = combine_datetime_with_qualifiers(dt, qualifiers)    62 show(l)    63     64 s = get_selector(dt, qualifiers)    65 l = s.materialise(dt, (2003, 12, 24, 0, 0, 0))    66 print len(l) == 32, 32, len(l)    67 print l[0] == (1997, 1, 11, 8, 30, 0), (1997, 1, 11, 8, 30, 0), l[0]    68 print l[-1] == (2003, 1, 25, 9, 30, 0), (2003, 1, 25, 9, 30, 0), l[-1]    69 print    70     71 qualifiers = [    72     ("DAILY", {"interval" : 1})    73     ]    74     75 l = order_qualifiers(qualifiers)    76 show(l)    77 dt = (1997, 9, 2, 9, 0, 0)    78 l = get_datetime_structure(dt)    79 show(l)    80 l = combine_datetime_with_qualifiers(dt, qualifiers)    81 show(l)    82     83 s = get_selector(dt, qualifiers)    84 l = s.materialise(dt, (1997, 12, 24), 10)    85 print len(l) == 10, 10, len(l)    86 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]    87 print l[-1] == (1997, 9, 11, 9, 0, 0), (1997, 9, 11, 9, 0, 0), l[-1]    88 print    89     90 qualifiers = [    91     ("DAILY", {"interval" : 1})    92     ]    93     94 l = order_qualifiers(qualifiers)    95 show(l)    96 dt = (1997, 9, 2, 9, 0, 0)    97 l = get_datetime_structure(dt)    98 show(l)    99 l = combine_datetime_with_qualifiers(dt, qualifiers)   100 show(l)   101    102 s = get_selector(dt, qualifiers)   103 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   104 print len(l) == 113, 113, len(l)   105 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   106 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1]   107 print   108    109 qualifiers = [   110     ("DAILY", {"interval" : 2})   111     ]   112    113 l = order_qualifiers(qualifiers)   114 show(l)   115 dt = (1997, 9, 2, 9, 0, 0)   116 l = get_datetime_structure(dt)   117 show(l)   118 l = combine_datetime_with_qualifiers(dt, qualifiers)   119 show(l)   120    121 s = get_selector(dt, qualifiers)   122 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   123 print len(l) == 57, 57, len(l)   124 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   125 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1]   126 print   127    128 qualifiers = [   129     ("WEEKLY", {"interval" : 1})   130     ]   131    132 l = order_qualifiers(qualifiers)   133 show(l)   134 dt = (1997, 9, 2, 9, 0, 0)   135 l = get_datetime_structure(dt)   136 show(l)   137 l = combine_datetime_with_qualifiers(dt, qualifiers)   138 show(l)   139    140 s = get_selector(dt, qualifiers)   141 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   142 print len(l) == 17, 17, len(l)   143 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   144 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1]   145 print   146    147 qualifiers = [   148     ("DAILY", {"interval" : 10})   149     ]   150    151 l = order_qualifiers(qualifiers)   152 show(l)   153 dt = (1997, 9, 2, 9, 0, 0)   154 l = get_datetime_structure(dt)   155 show(l)   156 l = combine_datetime_with_qualifiers(dt, qualifiers)   157 show(l)   158    159 s = get_selector(dt, qualifiers)   160 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 5)   161 print len(l) == 5, 5, len(l)   162 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   163 print l[-1] == (1997, 10, 12, 9, 0, 0), (1997, 10, 12, 9, 0, 0), l[-1]   164 print   165    166 qualifiers = [   167     ("YEARLY", {"interval" : 1}),   168     ("BYMONTH", {"values" : [1]}),   169     ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None), (6, None), (7, None)]})   170     ]   171    172 l = order_qualifiers(qualifiers)   173 show(l)   174 dt = (1998, 1, 1, 9, 0, 0)   175 l = get_datetime_structure(dt)   176 show(l)   177 l = combine_datetime_with_qualifiers(dt, qualifiers)   178 show(l)   179    180 s = get_selector(dt, qualifiers)   181 l = s.materialise(dt, (2000, 1, 31, 14, 0, 0))   182 print len(l) == 93, 93, len(l)   183 print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0]   184 print l[-1] == (2000, 1, 31, 9, 0, 0), (2000, 1, 31, 9, 0, 0), l[-1]   185 print   186    187 qualifiers = [   188     ("DAILY", {"interval" : 1}),   189     ("BYMONTH", {"values" : [1]})   190     ]   191    192 l = order_qualifiers(qualifiers)   193 show(l)   194 dt = (1998, 1, 1, 9, 0, 0)   195 l = get_datetime_structure(dt)   196 show(l)   197 l = combine_datetime_with_qualifiers(dt, qualifiers)   198 show(l)   199    200 s = get_selector(dt, qualifiers)   201 l = s.materialise(dt, (2000, 1, 31, 14, 0, 0))   202 print len(l) == 93, 93, len(l)   203 print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0]   204 print l[-1] == (2000, 1, 31, 9, 0, 0), (2000, 1, 31, 9, 0, 0), l[-1]   205 print   206    207 qualifiers = [   208     ("WEEKLY", {"interval" : 1})   209     ]   210    211 l = order_qualifiers(qualifiers)   212 show(l)   213 dt = (1997, 9, 2, 9, 0, 0)   214 l = get_datetime_structure(dt)   215 show(l)   216 l = combine_datetime_with_qualifiers(dt, qualifiers)   217 show(l)   218    219 s = get_selector(dt, qualifiers)   220 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10)   221 print len(l) == 10, 10, len(l)   222 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   223 print l[-1] == (1997, 11, 4, 9, 0, 0), (1997, 11, 4, 9, 0, 0), l[-1]   224 print   225    226 qualifiers = [   227     ("WEEKLY", {"interval" : 1})   228     ]   229    230 l = order_qualifiers(qualifiers)   231 show(l)   232 dt = (1997, 9, 2, 9, 0, 0)   233 l = get_datetime_structure(dt)   234 show(l)   235 l = combine_datetime_with_qualifiers(dt, qualifiers)   236 show(l)   237    238 s = get_selector(dt, qualifiers)   239 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   240 print len(l) == 17, 17, len(l)   241 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   242 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1]   243 print   244    245 qualifiers = [   246     ("WEEKLY", {"interval" : 2})   247     ]   248    249 l = order_qualifiers(qualifiers)   250 show(l)   251 dt = (1997, 9, 2, 9, 0, 0)   252 l = get_datetime_structure(dt)   253 show(l)   254 l = combine_datetime_with_qualifiers(dt, qualifiers)   255 show(l)   256    257 s = get_selector(dt, qualifiers)   258 l = s.materialise(dt, (1998, 2, 20, 0, 0, 0))   259 print len(l) == 13, 13, len(l)   260 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   261 print l[-1] == (1998, 2, 17, 9, 0, 0), (1998, 2, 17, 9, 0, 0), l[-1]   262 print   263    264 qualifiers = [   265     ("WEEKLY", {"interval" : 1}),   266     ("BYDAY", {"values" : [(2, None), (4, None)]})   267     ]   268    269 l = order_qualifiers(qualifiers)   270 show(l)   271 dt = (1997, 9, 2, 9, 0, 0)   272 l = get_datetime_structure(dt)   273 show(l)   274 l = combine_datetime_with_qualifiers(dt, qualifiers)   275 show(l)   276    277 s = get_selector(dt, qualifiers)   278 l = s.materialise(dt, (1997, 10, 7, 9, 0, 0))   279 print len(l) == 10, 10, len(l)   280 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   281 print l[-1] == (1997, 10, 2, 9, 0, 0), (1997, 10, 2, 9, 0, 0), l[-1]   282 print   283    284 qualifiers = [   285     ("WEEKLY", {"interval" : 1}),   286     ("BYDAY", {"values" : [(2, None), (4, None)]})   287     ]   288    289 l = order_qualifiers(qualifiers)   290 show(l)   291 dt = (1997, 9, 2, 9, 0, 0)   292 l = get_datetime_structure(dt)   293 show(l)   294 l = combine_datetime_with_qualifiers(dt, qualifiers)   295 show(l)   296    297 s = get_selector(dt, qualifiers)   298 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10)   299 print len(l) == 10, 10, len(l)   300 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   301 print l[-1] == (1997, 10, 2, 9, 0, 0), (1997, 10, 2, 9, 0, 0), l[-1]   302 print   303    304 qualifiers = [   305     ("WEEKLY", {"interval" : 2}),   306     ("BYDAY", {"values" : [(1, None), (3, None), (5, None)]})   307     ]   308    309 l = order_qualifiers(qualifiers)   310 show(l)   311 dt = (1997, 9, 1, 9, 0, 0)   312 l = get_datetime_structure(dt)   313 show(l)   314 l = combine_datetime_with_qualifiers(dt, qualifiers)   315 show(l)   316    317 s = get_selector(dt, qualifiers)   318 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   319 print len(l) == 25, 25, len(l)   320 print l[0] == (1997, 9, 1, 9, 0, 0), (1997, 9, 1, 9, 0, 0), l[0]   321 print l[-1] == (1997, 12, 22, 9, 0, 0), (1997, 12, 22, 9, 0, 0), l[-1]   322 print   323    324 qualifiers = [   325     ("WEEKLY", {"interval" : 2}),   326     ("BYDAY", {"values" : [(2, None), (4, None)]})   327     ]   328    329 l = order_qualifiers(qualifiers)   330 show(l)   331 dt = (1997, 9, 2, 9, 0, 0)   332 l = get_datetime_structure(dt)   333 show(l)   334 l = combine_datetime_with_qualifiers(dt, qualifiers)   335 show(l)   336    337 s = get_selector(dt, qualifiers)   338 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 8)   339 print len(l) == 8, 8, len(l)   340 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   341 print l[-1] == (1997, 10, 16, 9, 0, 0), (1997, 10, 16, 9, 0, 0), l[-1]   342 print   343    344 qualifiers = [   345     ("MONTHLY", {"interval" : 1}),   346     ("BYDAY", {"values" : [(5, 1)]})   347     ]   348    349 l = order_qualifiers(qualifiers)   350 show(l)   351 dt = (1997, 9, 5, 9, 0, 0)   352 l = get_datetime_structure(dt)   353 show(l)   354 l = combine_datetime_with_qualifiers(dt, qualifiers)   355 show(l)   356    357 s = get_selector(dt, qualifiers)   358 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)   359 print len(l) == 10, 10, len(l)   360 print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0]   361 print l[-1] == (1998, 6, 5, 9, 0, 0), (1998, 6, 5, 9, 0, 0), l[-1]   362 print   363    364 qualifiers = [   365     ("MONTHLY", {"interval" : 1}),   366     ("BYDAY", {"values" : [(5, 1)]})   367     ]   368    369 l = order_qualifiers(qualifiers)   370 show(l)   371 dt = (1997, 9, 5, 9, 0, 0)   372 l = get_datetime_structure(dt)   373 show(l)   374 l = combine_datetime_with_qualifiers(dt, qualifiers)   375 show(l)   376    377 s = get_selector(dt, qualifiers)   378 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))   379 print len(l) == 4, 4, len(l)   380 print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0]   381 print l[-1] == (1997, 12, 5, 9, 0, 0), (1997, 12, 5, 9, 0, 0), l[-1]   382 print   383    384 qualifiers = [   385     ("MONTHLY", {"interval" : 2}),   386     ("BYDAY", {"values" : [(7, 1), (7, -1)]})   387     ]   388    389 l = order_qualifiers(qualifiers)   390 show(l)   391 dt = (1997, 9, 7, 9, 0, 0)   392 l = get_datetime_structure(dt)   393 show(l)   394 l = combine_datetime_with_qualifiers(dt, qualifiers)   395 show(l)   396    397 s = get_selector(dt, qualifiers)   398 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)   399 print len(l) == 10, 10, len(l)   400 print l[0] == (1997, 9, 7, 9, 0, 0), (1997, 9, 7, 9, 0, 0), l[0]   401 print l[-1] == (1998, 5, 31, 9, 0, 0), (1998, 5, 31, 9, 0, 0), l[-1]   402 print   403    404 qualifiers = [   405     ("MONTHLY", {"interval" : 1}),   406     ("BYDAY", {"values" : [(1, -2)]})   407     ]   408    409 l = order_qualifiers(qualifiers)   410 show(l)   411 dt = (1997, 9, 22, 9, 0, 0)   412 l = get_datetime_structure(dt)   413 show(l)   414 l = combine_datetime_with_qualifiers(dt, qualifiers)   415 show(l)   416    417 s = get_selector(dt, qualifiers)   418 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6)   419 print len(l) == 6, 6, len(l)   420 print l[0] == (1997, 9, 22, 9, 0, 0), (1997, 9, 22, 9, 0, 0), l[0]   421 print l[-1] == (1998, 2, 16, 9, 0, 0), (1998, 2, 16, 9, 0, 0), l[-1]   422 print   423    424 qualifiers = [   425     ("MONTHLY", {"interval" : 1}),   426     ("BYMONTHDAY", {"values" : [-3]})   427     ]   428    429 l = order_qualifiers(qualifiers)   430 show(l)   431 dt = (1997, 9, 28, 9, 0, 0)   432 l = get_datetime_structure(dt)   433 show(l)   434 l = combine_datetime_with_qualifiers(dt, qualifiers)   435 show(l)   436    437 s = get_selector(dt, qualifiers)   438 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6)   439 print len(l) == 6, 6, len(l)   440 print l[0] == (1997, 9, 28, 9, 0, 0), (1997, 9, 28, 9, 0, 0), l[0]   441 print l[-1] == (1998, 2, 26, 9, 0, 0), (1998, 2, 26, 9, 0, 0), l[-1]   442 print   443    444 qualifiers = [   445     ("MONTHLY", {"interval" : 1}),   446     ("BYMONTHDAY", {"values" : [2, 15]})   447     ]   448    449 l = order_qualifiers(qualifiers)   450 show(l)   451 dt = (1997, 9, 2, 9, 0, 0)   452 l = get_datetime_structure(dt)   453 show(l)   454 l = combine_datetime_with_qualifiers(dt, qualifiers)   455 show(l)   456    457 s = get_selector(dt, qualifiers)   458 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)   459 print len(l) == 10, 10, len(l)   460 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   461 print l[-1] == (1998, 1, 15, 9, 0, 0), (1998, 1, 15, 9, 0, 0), l[-1]   462 print   463    464 qualifiers = [   465     ("MONTHLY", {"interval" : 1}),   466     ("BYMONTHDAY", {"values" : [1, -1]})   467     ]   468    469 l = order_qualifiers(qualifiers)   470 show(l)   471 dt = (1997, 9, 30, 9, 0, 0)   472 l = get_datetime_structure(dt)   473 show(l)   474 l = combine_datetime_with_qualifiers(dt, qualifiers)   475 show(l)   476    477 s = get_selector(dt, qualifiers)   478 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)   479 print len(l) == 10, 10, len(l)   480 print l[0] == (1997, 9, 30, 9, 0, 0), (1997, 9, 30, 9, 0, 0), l[0]   481 print l[-1] == (1998, 2, 1, 9, 0, 0), (1998, 2, 1, 9, 0, 0), l[-1]   482 print   483    484 qualifiers = [   485     ("MONTHLY", {"interval" : 18}),   486     ("BYMONTHDAY", {"values" : [10, 11, 12, 13, 14, 15]})   487     ]   488    489 l = order_qualifiers(qualifiers)   490 show(l)   491 dt = (1997, 9, 10, 9, 0, 0)   492 l = get_datetime_structure(dt)   493 show(l)   494 l = combine_datetime_with_qualifiers(dt, qualifiers)   495 show(l)   496    497 s = get_selector(dt, qualifiers)   498 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0), 10)   499 print len(l) == 10, 10, len(l)   500 print l[0] == (1997, 9, 10, 9, 0, 0), (1997, 9, 10, 9, 0, 0), l[0]   501 print l[-1] == (1999, 3, 13, 9, 0, 0), (1999, 3, 13, 9, 0, 0), l[-1]   502 print   503    504 qualifiers = [   505     ("MONTHLY", {"interval" : 2}),   506     ("BYDAY", {"values" : [(2, None)]})   507     ]   508    509 l = order_qualifiers(qualifiers)   510 show(l)   511 dt = (1997, 9, 2, 9, 0, 0)   512 l = get_datetime_structure(dt)   513 show(l)   514 l = combine_datetime_with_qualifiers(dt, qualifiers)   515 show(l)   516    517 s = get_selector(dt, qualifiers)   518 l = s.materialise(dt, (1998, 4, 1, 0, 0, 0))   519 print len(l) == 18, 18, len(l)   520 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]   521 print l[-1] == (1998, 3, 31, 9, 0, 0), (1998, 3, 31, 9, 0, 0), l[-1]   522 print   523    524 qualifiers = [   525     ("YEARLY", {"interval" : 1}),   526     ("BYMONTH", {"values" : [6, 7]})   527     ]   528    529 l = order_qualifiers(qualifiers)   530 show(l)   531 dt = (1997, 6, 10, 9, 0, 0)   532 l = get_datetime_structure(dt)   533 show(l)   534 l = combine_datetime_with_qualifiers(dt, qualifiers)   535 show(l)   536    537 s = get_selector(dt, qualifiers)   538 l = s.materialise(dt, (2001, 12, 24, 0, 0, 0), 10)   539 print len(l) == 10, 10, len(l)   540 print l[0] == (1997, 6, 10, 9, 0, 0), (1997, 6, 10, 9, 0, 0), l[0]   541 print l[-1] == (2001, 7, 10, 9, 0, 0), (2001, 7, 10, 9, 0, 0), l[-1]   542 print   543    544 qualifiers = [   545     ("YEARLY", {"interval" : 2}),   546     ("BYMONTH", {"values" : [1, 2, 3]})   547     ]   548    549 l = order_qualifiers(qualifiers)   550 show(l)   551 dt = (1997, 3, 10, 9, 0, 0)   552 l = get_datetime_structure(dt)   553 show(l)   554 l = combine_datetime_with_qualifiers(dt, qualifiers)   555 show(l)   556    557 s = get_selector(dt, qualifiers)   558 l = s.materialise(dt, (2003, 12, 24, 0, 0, 0), 10)   559 print len(l) == 10, 10, len(l)   560 print l[0] == (1997, 3, 10, 9, 0, 0), (1997, 3, 10, 9, 0, 0), l[0]   561 print l[-1] == (2003, 3, 10, 9, 0, 0), (2003, 3, 10, 9, 0, 0), l[-1]   562 print   563    564 qualifiers = [   565     ("YEARLY", {"interval" : 3}),   566     ("BYYEARDAY", {"values" : [1, 100, 200]})   567     ]   568    569 l = order_qualifiers(qualifiers)   570 show(l)   571 dt = (1997, 1, 1, 9, 0, 0)   572 l = get_datetime_structure(dt)   573 show(l)   574 l = combine_datetime_with_qualifiers(dt, qualifiers)   575 show(l)   576    577 s = get_selector(dt, qualifiers)   578 l = s.materialise(dt, (2006, 2, 1, 0, 0, 0), 10)   579 print len(l) == 10, 10, len(l)   580 print l[0] == (1997, 1, 1, 9, 0, 0), (1997, 1, 1, 9, 0, 0), l[0]   581 print l[-1] == (2006, 1, 1, 9, 0, 0), (2006, 1, 1, 9, 0, 0), l[-1]   582 print   583    584 qualifiers = [   585     ("YEARLY", {"interval" : 1}),   586     ("BYDAY", {"values" : [(1, 20)]})   587     ]   588    589 l = order_qualifiers(qualifiers)   590 show(l)   591 dt = (1997, 5, 19, 9, 0, 0)   592 l = get_datetime_structure(dt)   593 show(l)   594 l = combine_datetime_with_qualifiers(dt, qualifiers)   595 show(l)   596    597 s = get_selector(dt, qualifiers)   598 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))   599 print len(l) == 3, 3, len(l)   600 print l[0] == (1997, 5, 19, 9, 0, 0), (1997, 5, 19, 9, 0, 0), l[0]   601 print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1]   602 print   603    604 """   605 qualifiers = [   606     ("YEARLY", {"interval" : 1}),   607     ("BYWEEKNO", {"values" : [20]}),   608     ("BYDAY", {"values" : [(1, None)]})   609     ]   610    611 l = order_qualifiers(qualifiers)   612 show(l)   613 dt = (1997, 5, 12, 9, 0, 0)   614 l = get_datetime_structure(dt)   615 show(l)   616 l = combine_datetime_with_qualifiers(dt, qualifiers)   617 show(l)   618    619 s = get_selector(dt, qualifiers)   620 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))   621 print len(l) == 3, 3, len(l)   622 print l[0] == (1997, 5, 12, 9, 0, 0), (1997, 5, 12, 9, 0, 0), l[0]   623 print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1]   624 print   625 """   626    627 qualifiers = [   628     ("YEARLY", {"interval" : 1}),   629     ("BYMONTH", {"values" : [3]}),   630     ("BYDAY", {"values" : [(4, None)]})   631     ]   632    633 l = order_qualifiers(qualifiers)   634 show(l)   635 dt = (1997, 3, 13, 9, 0, 0)   636 l = get_datetime_structure(dt)   637 show(l)   638 l = combine_datetime_with_qualifiers(dt, qualifiers)   639 show(l)   640    641 s = get_selector(dt, qualifiers)   642 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))   643 print len(l) == 11, 11, len(l)   644 print l[0] == (1997, 3, 13, 9, 0, 0), (1997, 3, 13, 9, 0, 0), l[0]   645 print l[-1] == (1999, 3, 25, 9, 0, 0), (1999, 3, 25, 9, 0, 0), l[-1]   646 print   647    648 qualifiers = [   649     ("YEARLY", {"interval" : 1}),   650     ("BYMONTH", {"values" : [6, 7, 8]}),   651     ("BYDAY", {"values" : [(4, None)]})   652     ]   653    654 l = order_qualifiers(qualifiers)   655 show(l)   656 dt = (1997, 6, 5, 9, 0, 0)   657 l = get_datetime_structure(dt)   658 show(l)   659 l = combine_datetime_with_qualifiers(dt, qualifiers)   660 show(l)   661    662 s = get_selector(dt, qualifiers)   663 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))   664 print len(l) == 39, 39, len(l)   665 print l[0] == (1997, 6, 5, 9, 0, 0), (1997, 6, 5, 9, 0, 0), l[0]   666 print l[-1] == (1999, 8, 26, 9, 0, 0), (1999, 8, 26, 9, 0, 0), l[-1]   667 print   668    669 qualifiers = [   670     ("MONTHLY", {"interval" : 1}),   671     ("BYMONTHDAY", {"values" : [13]}),   672     ("BYDAY", {"values" : [(5, None)]})   673     ]   674    675 l = order_qualifiers(qualifiers)   676 show(l)   677 dt = (1997, 9, 2, 9, 0, 0)   678 l = get_datetime_structure(dt)   679 show(l)   680 l = combine_datetime_with_qualifiers(dt, qualifiers)   681 show(l)   682    683 s = get_selector(dt, qualifiers)   684 l = s.materialise(dt, (2000, 12, 24, 0, 0, 0))   685 print len(l) == 5, 5, len(l)   686 print l[0] == (1998, 2, 13, 9, 0, 0), (1998, 2, 13, 9, 0, 0), l[0]   687 print l[-1] == (2000, 10, 13, 9, 0, 0), (2000, 10, 13, 9, 0, 0), l[-1]   688 print   689    690 qualifiers = [   691     ("MONTHLY", {"interval" : 1}),   692     ("BYMONTHDAY", {"values" : [7, 8, 9, 10, 11, 12, 13]}),   693     ("BYDAY", {"values" : [(6, None)]})   694     ]   695    696 l = order_qualifiers(qualifiers)   697 show(l)   698 dt = (1997, 9, 13, 9, 0, 0)   699 l = get_datetime_structure(dt)   700 show(l)   701 l = combine_datetime_with_qualifiers(dt, qualifiers)   702 show(l)   703    704 s = get_selector(dt, qualifiers)   705 l = s.materialise(dt, (1998, 6, 30, 0, 0, 0))   706 print len(l) == 10, 10, len(l)   707 print l[0] == (1997, 9, 13, 9, 0, 0), (1997, 9, 13, 9, 0, 0), l[0]   708 print l[-1] == (1998, 6, 13, 9, 0, 0), (1998, 6, 13, 9, 0, 0), l[-1]   709 print   710    711 qualifiers = [   712     ("YEARLY", {"interval" : 4}),   713     ("BYMONTH", {"values" : [11]}),   714     ("BYMONTHDAY", {"values" : [2, 3, 4, 5, 6, 7, 8]}),   715     ("BYDAY", {"values" : [(2, None)]})   716     ]   717    718 l = order_qualifiers(qualifiers)   719 show(l)   720 dt = (1996, 11, 5, 9, 0, 0)   721 l = get_datetime_structure(dt)   722 show(l)   723 l = combine_datetime_with_qualifiers(dt, qualifiers)   724 show(l)   725    726 s = get_selector(dt, qualifiers)   727 l = s.materialise(dt, (2004, 12, 24, 0, 0, 0))   728 print len(l) == 3, 3, len(l)   729 print l[0] == (1996, 11, 5, 9, 0, 0), (1996, 11, 5, 9, 0, 0), l[0]   730 print l[-1] == (2004, 11, 2, 9, 0, 0), (2004, 11, 2, 9, 0, 0), l[-1]   731 print   732    733 qualifiers = [   734     ("MONTHLY", {"interval" : 1}),   735     ("BYDAY", {"values" : [(2, None), (3, None), (4, None)]})   736     ]   737    738 l = order_qualifiers(qualifiers)   739 show(l)   740 dt = (1997, 9, 4, 9, 0, 0)   741 l = get_datetime_structure(dt)   742 show(l)   743 l = combine_datetime_with_qualifiers(dt, qualifiers)   744 show(l)   745    746 s = get_selector(dt, qualifiers)   747 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 3, [3])   748 print len(l) == 3, 3, len(l)   749 print l[0] == (1997, 9, 4, 9, 0, 0), (1997, 9, 4, 9, 0, 0), l[0]   750 print l[-1] == (1997, 11, 6, 9, 0, 0), (1997, 11, 6, 9, 0, 0), l[-1]   751 print   752    753 l2 = l   754    755 qualifiers = [   756     ("MONTHLY", {"interval" : 1}),   757     ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None)]})   758     ]   759    760 l = order_qualifiers(qualifiers)   761 show(l)   762 dt = (1997, 9, 29, 9, 0, 0)   763 l = get_datetime_structure(dt)   764 show(l)   765 l = combine_datetime_with_qualifiers(dt, qualifiers)   766 show(l)   767    768 s = get_selector(dt, qualifiers)   769 l = s.materialise(dt, (1998, 4, 1, 0, 0, 0), None, [-2])   770 print len(l) == 7, 7, len(l)   771 print l[0] == (1997, 9, 29, 9, 0, 0), (1997, 9, 29, 9, 0, 0), l[0]   772 print l[-1] == (1998, 3, 30, 9, 0, 0), (1998, 3, 30, 9, 0, 0), l[-1]   773 print   774    775 qualifiers = get_qualifiers(["FREQ=MONTHLY", "BYMONTHDAY=5", "FREQ=HOURLY", "INTERVAL=12"])   776    777 l = order_qualifiers(qualifiers)   778 show(l)   779 dt = (2017, 6, 13)   780 l = get_datetime_structure(dt)   781 show(l)   782 l = combine_datetime_with_qualifiers(dt, qualifiers)   783 show(l)   784    785 s = get_selector(dt, qualifiers)   786 l = s.materialise(dt, (2019, 1, 1))   787 print len(l) == 36   788 print l[0] == (2017, 7, 5, 0), (2017, 7, 5, 0), l[0]   789 print l[-1] == (2018, 12, 5, 12), (2018, 12, 5, 12), l[-1]   790    791 qualifiers = get_qualifiers(["FREQ=DAILY", "BYMONTH=1"])   792    793 l = order_qualifiers(qualifiers)   794 show(l)   795 dt = (2017, 6, 13)   796 l = get_datetime_structure(dt)   797 show(l)   798 l = combine_datetime_with_qualifiers(dt, qualifiers)   799 show(l)   800    801 s = get_selector(dt, qualifiers)   802 l = s.materialise(dt, (2019, 1, 1))   803 print len(l) == 31   804 print l[0] == (2018, 1, 1), (2018, 1, 1), l[0]   805 print l[-1] == (2018, 1, 31), (2018, 1, 31), l[-1]   806    807 # vim: tabstop=4 expandtab shiftwidth=4