imip-agent

Annotated tests/internal/qualifiers.py

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