~edwinvandeven/openstudio/2017.0

« back to all changes in this revision

Viewing changes to tests/controllers/test_03_customers_controller.py

  • Committer: Edwin van de Ven
  • Date: 2017-10-10 11:43:48 UTC
  • Revision ID: edwinvandeven@home.nl-20171010114348-kjon60md9vz6n4uf
Added test for profile cancel orders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
'''py.test test cases to test OpenStudio.
4
 
 
5
 
These tests run based on webclient and need web2py server running.
6
 
'''
7
 
 
8
 
import datetime
9
 
import calendar
10
 
from gluon.contrib.populate import populate
11
 
from populate_os_tables import prepare_classes
12
 
from populate_os_tables import populate_classes
13
 
from populate_os_tables import populate_customers
14
 
from populate_os_tables import populate_customers_with_subscriptions
15
 
from populate_os_tables import populate_customers_with_classcards
16
 
from populate_os_tables import populate_customers_payment_info
17
 
from populate_os_tables import populate_workshops_products_customers
18
 
from populate_os_tables import populate_workshops_with_activity
19
 
from populate_os_tables import populate_school_subscriptions
20
 
from populate_os_tables import populate_school_classcards
21
 
 
22
 
def test_customers_add(client, web2py):
23
 
    '''
24
 
        Created a customer?
25
 
    '''
26
 
    client.get('/customers/add')
27
 
    assert 'name="first_name"' in client.text
28
 
    assert 'name="last_name"' in client.text
29
 
    data = dict(first_name='Edwin',
30
 
                last_name='van de Ven',
31
 
                email='test@openstudioproject.com',
32
 
                )
33
 
    client.post('/customers/add', data=data)
34
 
    assert client.status == 200
35
 
    assert 'Profile' in client.text # verify redirection to edit page
36
 
 
37
 
    client.get('/customers')
38
 
    assert client.status == 200
39
 
    assert data['first_name'] in client.text
40
 
    assert data['last_name'] in client.text
41
 
    assert not 'class="error"' in client.text # make sure the form validated
42
 
 
43
 
    assert web2py.db(web2py.db.auth_user).count() == 2 # customer we just created and admin user
44
 
    assert web2py.db(web2py.db.auth_user.first_name == data['first_name']).count() == 1
45
 
 
46
 
 
47
 
def test_customers_edit(client, web2py):
48
 
    '''
49
 
        Can we edit a customer
50
 
    '''
51
 
    populate_customers(web2py)
52
 
    assert web2py.db(web2py.db.auth_user).count() > 0
53
 
 
54
 
    url = '/customers/edit/1001'
55
 
    client.get(url)
56
 
    assert client.status == 200
57
 
 
58
 
    data = {
59
 
        'id'            : 1001,
60
 
        'first_name'    : 'gorilla',
61
 
        'last_name'     : 'monkey',
62
 
        'email'         : 'gorilla@monkey.nl'
63
 
    }
64
 
 
65
 
    client.post(url, data=data)
66
 
    assert client.status == 200
67
 
 
68
 
    customer = web2py.db.auth_user(1001)
69
 
    assert customer.first_name == data['first_name']
70
 
 
71
 
 
72
 
 
73
 
def test_customers_edit_teacher(client, web2py):
74
 
    ''''
75
 
        Is the edit teacher page accepting submitted data?
76
 
    '''
77
 
    populate_customers(web2py, 2)
78
 
    assert web2py.db(web2py.db.auth_user).count() > 0
79
 
 
80
 
    url = '/customers/edit_teacher?cuID=1001'
81
 
    client.get(url)
82
 
    assert client.status == 200
83
 
 
84
 
    data = {
85
 
        'id'                : 1001,
86
 
        'teacher_bio'       : 'bananas',
87
 
        'education'         : 'cherries',
88
 
        'teacher_bio_link'  : 'mangoes',
89
 
        'teacher_website'   : 'pineapple'
90
 
    }
91
 
 
92
 
    client.post(url, data=data)
93
 
    assert client.status == 200
94
 
 
95
 
    customer = web2py.db.auth_user(1001)
96
 
 
97
 
    assert customer.teacher_bio == data['teacher_bio']
98
 
    assert customer.teacher_website == data['teacher_website']
99
 
 
100
 
 
101
 
def test_customers_archive(client, web2py):
102
 
    '''
103
 
        Can we archive a customer?
104
 
    '''
105
 
    populate_customers(web2py, 1)
106
 
    assert web2py.db(web2py.db.auth_user).count() == 1
107
 
 
108
 
    # archive
109
 
    client.get('/customers/archive?uID=1001')
110
 
    assert client.status == 200
111
 
 
112
 
    query = (web2py.db.auth_user.archived == True)
113
 
    assert web2py.db(query).count() == 1
114
 
 
115
 
    # move to current
116
 
    client.get('/customers/archive?uID=1001')
117
 
    assert client.status == 200
118
 
 
119
 
    query = (web2py.db.auth_user.archived == True)
120
 
    assert web2py.db(query).count() == 0
121
 
 
122
 
 
123
 
def test_load_list_birthday_icon(client, web2py):
124
 
    '''
125
 
        Is the birthday icon showing in load_list
126
 
    '''
127
 
    populate_customers(web2py, 1)
128
 
 
129
 
    # make it the first customers' birthday today
130
 
    today = datetime.date.today()
131
 
    customer = web2py.db.auth_user(1001)
132
 
    customer.date_of_birth = today
133
 
    customer.birthday = datetime.date(1900, today.month, today.day)
134
 
    customer.update_record()
135
 
 
136
 
    web2py.db.commit()
137
 
 
138
 
    url = '/customers/load_list?list_type=customers_index&initial_list=True&archived=False&items_per_page=7'
139
 
    client.get(url)
140
 
    assert client.status == 200
141
 
    assert 'fa-birthday-cake' in client.text
142
 
 
143
 
 
144
 
def populate_account_merge(client, web2py):
145
 
    '''
146
 
        Populates all tables with reference to auth_user for user 1002
147
 
        Also created user 1001 so we have an id to merge into
148
 
    '''
149
 
    # get a random url to initialize payment methods
150
 
    url = '/default/user/login'
151
 
    client.get(url)
152
 
    assert client.status == 200
153
 
 
154
 
    merge_into_id = 1001
155
 
    merge_from_id = 1002
156
 
 
157
 
    prepare_classes(web2py, nr_of_customers=2, cuID=merge_from_id)
158
 
    # let's make merge_from_id a teacher as well
159
 
    user = web2py.db.auth_user(merge_from_id)
160
 
    user.teacher = True
161
 
    user.enabled = True
162
 
    user.update_record()
163
 
 
164
 
    populate_customers_payment_info(web2py, 2)
165
 
 
166
 
    # remove payment info for merge_into_id, so we're sure that the info from merge_from_id appears in the test data
167
 
    query = (web2py.db.customers_payment_info.auth_customer_id == merge_into_id)
168
 
    web2py.db(query).delete()
169
 
 
170
 
    populate_school_subscriptions(web2py)
171
 
    web2py.db.customers_subscriptions.insert(
172
 
        auth_customer_id        = merge_from_id,
173
 
        school_subscriptions_id = 1,
174
 
        Startdate               = '2014-01-01',
175
 
        payment_methods_id      = 3
176
 
        )
177
 
 
178
 
    populate_school_classcards(web2py)
179
 
    web2py.db.customers_classcards.insert(
180
 
        auth_customer_id      = merge_from_id,
181
 
        school_classcards_id  = 1,
182
 
        Startdate             = '2014-01-01',
183
 
        Enddate               = '2014-01-31'
184
 
        )
185
 
 
186
 
    web2py.db.customers_notes.insert(
187
 
        auth_customer_id = merge_from_id,
188
 
        auth_user_id     = merge_from_id, # to check if the task assignment also mergesz
189
 
        BackofficeNote   = True,
190
 
        NoteDate         = '2014-01-01',
191
 
        NoteTime         = '17:00',
192
 
        Note             = 'Test note',
193
 
        )
194
 
 
195
 
    web2py.db.tasks.insert(
196
 
        auth_customer_id = merge_from_id,
197
 
        Task             = 'Fix some bugs',
198
 
        Description      = 'Test',
199
 
        Duedate          = '2014-02-01',
200
 
        auth_user_id     = merge_from_id, # to check if the task assignment also merges
201
 
        )
202
 
 
203
 
    web2py.db.alternativepayments.insert(
204
 
        auth_customer_id    = merge_from_id,
205
 
        PaymentYear         = 2014,
206
 
        PaymentMonth        = 1,
207
 
        Amount              = 12.03,
208
 
        Description         = 'test'
209
 
        )
210
 
 
211
 
    iID = web2py.db.invoices.insert(
212
 
        invoices_groups_id      = 100,
213
 
        auth_customer_id        = merge_from_id,
214
 
        payment_methods_id      = 3,
215
 
        Status                  = 'sent',
216
 
        InvoiceID               = 'INV' + unicode(merge_from_id),
217
 
        DateCreated             = '2014-01-01',
218
 
        DateDue                 = '2014-01-31'
219
 
        )
220
 
 
221
 
    web2py.db.invoices_amounts.insert(invoices_id = iID)
222
 
 
223
 
    web2py.db.payment_batches.insert(
224
 
        BatchType     = 'collection',
225
 
        Name          = 'test',
226
 
        Description   = 'test',
227
 
        ColYear       = 2014,
228
 
        ColMonth      = 1,
229
 
        Exdate        = '2014-01-01'
230
 
        )
231
 
    web2py.db.payment_batches_items.insert(
232
 
        payment_batches_id    = 1,
233
 
        auth_customer_id      = merge_from_id,
234
 
        )
235
 
 
236
 
    web2py.db.customers_payments.insert(
237
 
        auth_customer_id    = merge_from_id,
238
 
        Amount              = 1434.12,
239
 
        PaymentDate         = '2014-01-01',
240
 
        payment_methods_id  = 3,
241
 
        )
242
 
 
243
 
    web2py.db.customers_documents.insert(
244
 
        auth_customer_id    = merge_from_id,
245
 
        Description         = 'test',
246
 
        DocumentFile        = 'DocumentFile.txt',
247
 
        )
248
 
 
249
 
    populate(web2py.db.messages, 1)
250
 
    web2py.db.customers_messages.insert(
251
 
        auth_customer_id    = merge_from_id,
252
 
        messages_id         = 1,
253
 
        Status              = 'fail',
254
 
        )
255
 
 
256
 
    populate_workshops_with_activity(web2py, teachers=False)
257
 
    web2py.db.workshops_products_customers.insert(
258
 
        auth_customer_id      = merge_from_id,
259
 
        workshops_products_id = 1
260
 
        )
261
 
    web2py.db.workshops_activities_customers.insert(
262
 
        auth_customer_id        = merge_from_id,
263
 
        workshops_activities_id = 1
264
 
        )
265
 
 
266
 
    # customer tables end
267
 
 
268
 
    # teacher tables begin
269
 
 
270
 
    web2py.db.teachers_holidays.insert(
271
 
        auth_teacher_id = merge_from_id,
272
 
        Startdate       = '2014-01-01',
273
 
        Enddate         = '2014-01-31',
274
 
        Note            = 'Winter holiday'
275
 
        )
276
 
 
277
 
    web2py.db.teachers_classtypes.insert(
278
 
        auth_user_id          = merge_from_id,
279
 
        school_classtypes_id = 1
280
 
        )
281
 
 
282
 
    cl_te = web2py.db.classes_teachers(1) # from prepare_classes
283
 
    cl_te.auth_teacher_id  = merge_from_id
284
 
    cl_te.auth_teacher_id2 = merge_from_id
285
 
    cl_te.update_record()
286
 
 
287
 
    web2py.db.classes_subteachers.insert(
288
 
        classes_id        = 1,
289
 
        ClassDate         = '2014-01-06',
290
 
        auth_teacher_id   = merge_from_id,
291
 
        auth_teacher_id2  = merge_from_id
292
 
        )
293
 
 
294
 
    workshop = web2py.db.workshops(1)
295
 
    workshop.auth_teacher_id  = merge_from_id
296
 
    workshop.auth_teacher_id2 = merge_from_id
297
 
    workshop.update_record()
298
 
 
299
 
    wsa = web2py.db.workshops_activities(1)
300
 
    wsa.auth_teacher_id  = merge_from_id
301
 
    wsa.auth_teacher_id2 = merge_from_id
302
 
    wsa.update_record()
303
 
 
304
 
    # teacher tables end
305
 
 
306
 
    # user tables begin
307
 
 
308
 
    web2py.db.payment_batches_exports.insert(
309
 
        auth_user_id       = merge_from_id,
310
 
        payment_batches_id = 1,
311
 
        )
312
 
 
313
 
    # user tables end
314
 
 
315
 
    web2py.db.commit()
316
 
 
317
 
 
318
 
def test_account_merge(client, web2py):
319
 
    '''
320
 
        Can we merge an account?
321
 
        We'll create 2 customers, attach all data to 2nd customer,
322
 
        then merge into first and check if we still have all data.
323
 
    '''
324
 
    def assert_count_customer(table, count):
325
 
        print 'Testing customer table: ' + unicode(table)
326
 
        query = (table.auth_customer_id == 1001)
327
 
        #print web2py.db().select(table.ALL)
328
 
 
329
 
        assert web2py.db(query).count() == count
330
 
        print 'OK'
331
 
 
332
 
    def assert_count_user(table, count):
333
 
        print 'Testing user table: ' + unicode(table)
334
 
        query = (table.auth_user_id == 1001)
335
 
        assert web2py.db(query).count() == count
336
 
        print 'OK'
337
 
 
338
 
    def assert_count_teacher(table, count):
339
 
        print 'Testing teacher table: ' + unicode(table)
340
 
        query = (table.auth_teacher_id == 1001)
341
 
        assert web2py.db(query).count() == count
342
 
        print 'OK'
343
 
 
344
 
    def assert_count_teacher2(table, count):
345
 
        print 'Testing teacher2 table: ' + unicode(table)
346
 
        query = (table.auth_teacher_id2 == 1001)
347
 
        assert web2py.db(query).count() == count
348
 
        print 'OK'
349
 
 
350
 
    populate_account_merge(client, web2py)
351
 
 
352
 
    # Execute the merge
353
 
    auth_merge_id = 1002
354
 
    url = '/customers/account_merge_execute?cuID=1001&auth_merge_id=' + unicode(auth_merge_id)
355
 
    client.get(url)
356
 
    assert client.status == 200
357
 
 
358
 
    ## check all tables in the DB
359
 
    customer_tables = [
360
 
        [ 1, web2py.db.alternativepayments ],
361
 
        [ 4, web2py.db.classes_attendance ],
362
 
        [ 3, web2py.db.classes_reservation ],
363
 
        [ 1, web2py.db.classes_waitinglist ],
364
 
        [ 3, web2py.db.customers_classcards ],
365
 
        [ 1, web2py.db.customers_documents ],
366
 
        [ 1, web2py.db.customers_messages ],
367
 
        [ 2, web2py.db.customers_payment_info ],
368
 
        [ 1, web2py.db.customers_payments ],
369
 
        [ 3, web2py.db.customers_subscriptions ],
370
 
        [ 1, web2py.db.customers_notes ],
371
 
        [ 1, web2py.db.invoices ],
372
 
        [ 1, web2py.db.payment_batches_items ],
373
 
        [ 1, web2py.db.tasks ],
374
 
        [ 1, web2py.db.workshops_activities_customers ],
375
 
        [ 1, web2py.db.workshops_products_customers ]
376
 
        ]
377
 
 
378
 
    for count, table in customer_tables:
379
 
        assert_count_customer(table, count)
380
 
 
381
 
    auth_user_tables = [
382
 
        [ 1, web2py.db.customers_notes ],
383
 
        [ 1, web2py.db.payment_batches_exports ],
384
 
        [ 1, web2py.db.tasks ],
385
 
        ]
386
 
 
387
 
    for count, table in auth_user_tables:
388
 
        assert_count_user(table, count)
389
 
 
390
 
    auth_teacher_tables = [
391
 
        [ 1, web2py.db.classes_teachers ],
392
 
        [ 1, web2py.db.classes_subteachers ],
393
 
        [ 1, web2py.db.teachers_holidays ],
394
 
        [ 1, web2py.db.workshops ],
395
 
        [ 1, web2py.db.workshops_activities ],
396
 
        ]
397
 
 
398
 
    for count, table in auth_teacher_tables:
399
 
        assert_count_teacher(table, count)
400
 
 
401
 
    auth_teacher2_tables = [
402
 
        [ 1, web2py.db.classes_teachers ],
403
 
        [ 1, web2py.db.classes_subteachers ],
404
 
        [ 1, web2py.db.workshops ],
405
 
        [ 1, web2py.db.workshops_activities ],
406
 
        ]
407
 
 
408
 
    for count, table in auth_teacher2_tables:
409
 
        assert_count_teacher2(table, count)
410
 
 
411
 
 
412
 
    # check if the user is a teacher now
413
 
    user = web2py.db.auth_user(1001)
414
 
    assert user.teacher == True
415
 
    assert user.enabled == True
416
 
 
417
 
 
418
 
    merged_user = web2py.db.auth_user(1002)
419
 
    assert merged_user.merged
420
 
    assert merged_user.merged_into == 1001
421
 
    assert not merged_user.merged_on is None
422
 
 
423
 
    # verify the flash message
424
 
    assert 'Merge success' in client.text
425
 
 
426
 
 
427
 
def test_customers_subscription_add(client, web2py):
428
 
    '''
429
 
        Can we add a customers_subscription?
430
 
    '''
431
 
    populate_school_subscriptions(web2py)
432
 
    populate_customers(web2py)
433
 
    assert web2py.db(web2py.db.school_subscriptions).count() > 0
434
 
    assert web2py.db(web2py.db.auth_user).count() > 0
435
 
 
436
 
    url = '/customers/subscription_add/?cuID=1'
437
 
 
438
 
    client.get(url)
439
 
    assert client.status == 200
440
 
 
441
 
    data = dict(school_subscriptions_id='1',
442
 
                Startdate='2014-01-01',
443
 
                )
444
 
    client.post(url, data=data)
445
 
    assert client.status == 200
446
 
    assert web2py.db(web2py.db.customers_subscriptions).count() == 1
447
 
 
448
 
    mstype_name = web2py.db.school_subscriptions(1).Name
449
 
 
450
 
    client.get('/customers/subscriptions?cuID=1')
451
 
    assert client.status == 200
452
 
    assert mstype_name in client.text
453
 
 
454
 
 
455
 
def populate_customer_subscriptions(client, web2py):
456
 
    # get random url to initialize payment methods in db
457
 
    url = '/default/user/login'
458
 
    client.get(url)
459
 
    assert client.status == 200
460
 
 
461
 
    populate_school_subscriptions(web2py)
462
 
    populate_customers(web2py)
463
 
    web2py.db.customers_subscriptions.insert(
464
 
        auth_customer_id        = 1001,
465
 
        school_subscriptions_id = 1,
466
 
        Startdate               = '2014-01-01',
467
 
        payment_methods_id      = 3,
468
 
        Note                    = "Hello world!")
469
 
 
470
 
    web2py.db.commit()
471
 
 
472
 
    assert web2py.db(web2py.db.school_subscriptions).count() > 0
473
 
    assert web2py.db(web2py.db.auth_user).count() > 0
474
 
    assert web2py.db(web2py.db.customers_subscriptions).count() > 0
475
 
 
476
 
 
477
 
def populate_customer_subscriptions_paused(client, web2py):
478
 
    '''
479
 
        Adds pause to subcription starting from 2014-01-01
480
 
    '''
481
 
    populate_customer_subscriptions(client, web2py)
482
 
 
483
 
    web2py.db.customers_subscriptions_paused.insert(
484
 
        customers_subscriptions_id = 1,
485
 
        Startdate                  = '2014-01-01',
486
 
        Enddate                    = '2014-01-31',
487
 
        Description                = 'Bananas')
488
 
 
489
 
    web2py.db.commit()
490
 
 
491
 
 
492
 
def test_customers_subscription_edit(client, web2py):
493
 
    '''
494
 
        can we edit a subscription?
495
 
    '''
496
 
    populate_customer_subscriptions(client, web2py)
497
 
 
498
 
    url = '/customers/subscription_edit?cuID=1001&csID=1'
499
 
 
500
 
    client.get(url)
501
 
    assert client.status == 200
502
 
    assert web2py.db(web2py.db.customers_subscriptions).count() == 1
503
 
 
504
 
    data = dict(id=1,
505
 
                school_subscriptions_id = '1',
506
 
                Startdate               = '2016-01-01',
507
 
                )
508
 
    client.post(url, data=data)
509
 
    assert client.status == 200
510
 
 
511
 
    assert 'Subscriptions' in client.text # verify redirection to customers/subscriptions
512
 
    assert data['Startdate'] in client.text
513
 
 
514
 
 
515
 
def test_customers_subscription_delete(client, web2py):
516
 
    '''
517
 
        Is the custom delete function for customer subscriptions working?
518
 
    '''
519
 
    # get random url to initialize payment methods
520
 
    url = '/default/user/login'
521
 
    client.get(url)
522
 
    assert client.status == 200
523
 
 
524
 
    populate_customers_with_subscriptions(web2py, 2)
525
 
 
526
 
    # insert invoice and check that the subscription isn't deletable anymore
527
 
    web2py.db.invoices.insert(
528
 
        invoices_groups_id          = 100,
529
 
        auth_customer_id            = 1001,
530
 
        customers_subscriptions_id  = 1,
531
 
        SubscriptionMonth           = 1,
532
 
        SubscriptionYear            = 2014,
533
 
        Status                      = 'sent',
534
 
        DateCreated                 = '2014-01-01',
535
 
        DateDue                     = '2014-01-31',
536
 
    )
537
 
 
538
 
    web2py.db.commit()
539
 
 
540
 
    url = '/customers/subscription_delete?cuID=1001&csID=1'
541
 
    client.get(url)
542
 
    assert client.status == 200
543
 
 
544
 
    assert 'Unable to delete' in client.text
545
 
 
546
 
    # now remove invoices and try again
547
 
    web2py.db(web2py.db.invoices.id > 0).delete()
548
 
    web2py.db.commit()
549
 
 
550
 
    url = '/customers/subscription_delete?cuID=1001&csID=1'
551
 
    client.get(url)
552
 
    assert client.status == 200
553
 
 
554
 
    assert 'Deleted subscription' in client.text
555
 
 
556
 
 
557
 
def test_customers_subscriptions_list_recent_pauses(client, web2py):
558
 
    '''
559
 
        Is the list of paused subscriptions showing?
560
 
    '''
561
 
    # get random url to initialize payment methods in db
562
 
    url = '/default/user/login'
563
 
    client.get(url)
564
 
    assert client.status == 200
565
 
 
566
 
    populate_customer_subscriptions_paused(client, web2py)
567
 
 
568
 
    assert web2py.db(web2py.db.customers_subscriptions).count() == 1
569
 
 
570
 
    client.get('/customers/subscriptions?cuID=1001')
571
 
    assert client.status == 200
572
 
    assert 'Pauses' in client.text
573
 
 
574
 
    # check recent pauses
575
 
    assert '2014-01-01 - 2014-01-31' in client.text
576
 
 
577
 
 
578
 
def test_customers_subscriptions_pauses(client, web2py):
579
 
    '''
580
 
        Is the list of pauzed showing?
581
 
    '''
582
 
    # get random url to initialize payment methods in db
583
 
    url = '/default/user/login'
584
 
    client.get(url)
585
 
    assert client.status == 200
586
 
 
587
 
    populate_customer_subscriptions_paused(client, web2py)
588
 
 
589
 
    assert web2py.db(web2py.db.customers_subscriptions).count() == 1
590
 
 
591
 
    client.get('/customers/subscription_pauses?csID=1&cuID=1001')
592
 
    assert client.status == 200
593
 
    assert 'Pauses' in client.text
594
 
 
595
 
    # check listing
596
 
    pause = web2py.db.customers_subscriptions_paused(1)
597
 
    assert pause.Description in client.text
598
 
 
599
 
 
600
 
def test_customers_subscriptions_pause_add(client, web2py):
601
 
    '''
602
 
        Test adding of a pause
603
 
    '''
604
 
    # get random url to initialize payment methods in db
605
 
    url = '/default/user/login'
606
 
    client.get(url)
607
 
    assert client.status == 200
608
 
 
609
 
    populate_customer_subscriptions(client, web2py)
610
 
 
611
 
    url = '/customers/subscription_pause_add?csID=1'
612
 
    client.get(url)
613
 
    assert client.status == 200
614
 
 
615
 
    data = {'from_month'   : '1',
616
 
            'from_year'    : '2014',
617
 
            'until_month'  : '2',
618
 
            'until_year'   : '2',
619
 
            'description'  : 'Custard apple'}
620
 
    client.post(url, data=data)
621
 
    assert client.status == 200
622
 
 
623
 
    # verify redirection
624
 
    assert 'Subscriptions' in client.text
625
 
 
626
 
    # verify display
627
 
    assert data['description'] in client.text
628
 
 
629
 
    # verify database
630
 
    assert web2py.db(web2py.db.customers_subscriptions_paused).count() == 1
631
 
 
632
 
 
633
 
def test_classcard_add_classic(client, web2py):
634
 
    '''
635
 
        Add a classcard using a drop down menu
636
 
    '''
637
 
    populate_school_classcards(web2py, 8, trialcard = True)
638
 
    populate_customers(web2py, 1)
639
 
 
640
 
    # check redirection of add_classcard
641
 
    url = '/customers/classcard_add?cuID=1'
642
 
    client.get(url)
643
 
    assert client.status == 200
644
 
    assert not 'panel-primary' in client.text
645
 
 
646
 
    # check automatic calculating of enddate
647
 
    url = '/customers/classcard_add_classic?cuID=1'
648
 
    data = {'school_classcards_id' :  1,
649
 
            'Startdate'            : '2014-01-01',
650
 
            'Note'                 : 'Bananas'}
651
 
    client.post(url, data=data)
652
 
    assert client.status == 200
653
 
 
654
 
    # check db
655
 
    assert web2py.db(web2py.db.customers_classcards).count() == 1
656
 
    # check automatich adding of enddate
657
 
    assert web2py.db.customers_classcards(1).Enddate == datetime.date(2014, 3, 31)
658
 
 
659
 
    # check classcard invoice
660
 
    check_classcard_invoice(web2py)
661
 
 
662
 
 
663
 
def check_classcard_invoice(web2py):
664
 
    '''
665
 
        Check if an invoice is created correctly after adding a classcard
666
 
        to a customer
667
 
    '''
668
 
    assert web2py.db(web2py.db.invoices).count() == 1
669
 
    invoice = web2py.db.invoices(1)
670
 
    assert invoice.invoices_groups_id == 100
671
 
 
672
 
    iccd = web2py.db.invoices_customers_classcards(1)
673
 
    assert iccd.customers_classcards_id == 1
674
 
 
675
 
    price = web2py.db.school_classcards(1).Price
676
 
    invoice_amount = web2py.db.invoices_amounts(1).TotalPriceVAT
677
 
 
678
 
    assert price == invoice_amount
679
 
 
680
 
 
681
 
def test_classcard_add_classic_trialcard_removed_after_getting_one(client, web2py):
682
 
    '''
683
 
        Check that the trialcard options are no longer listed
684
 
    '''
685
 
    nr_cards = 10
686
 
    populate_school_classcards(web2py, nr_cards, trialcard = True)
687
 
    populate_customers(web2py, 1)
688
 
 
689
 
    trialcard_id = nr_cards + 1
690
 
 
691
 
    web2py.db.customers_classcards.insert(
692
 
        auth_customer_id = 1001,
693
 
        school_classcards_id = trialcard_id,
694
 
        Startdate = '2014-01-01',
695
 
        Enddate = '2014-01-31',
696
 
        Note = 'Cherries' )
697
 
 
698
 
    web2py.db.commit()
699
 
    # check db
700
 
    assert web2py.db(web2py.db.customers_classcards).count() == 1
701
 
 
702
 
    # check automatic calculating of enddate
703
 
    url = '/customers/classcard_add_classic?cuID=1001'
704
 
    client.get(url)
705
 
    assert client.status == 200
706
 
    assert web2py.db.school_classcards(trialcard_id).Name not in client.text
707
 
 
708
 
 
709
 
def test_classcard_add_modern(client, web2py):
710
 
    '''
711
 
        Add a classcard using fancy layout
712
 
    '''
713
 
    populate_school_classcards(web2py, 6, trialcard = True)
714
 
    populate_customers(web2py, 1)
715
 
 
716
 
    # check redirection of add_classcard
717
 
    url = '/customers/classcard_add?cuID=1'
718
 
    client.get(url)
719
 
    assert client.status == 200
720
 
    assert 'panel-primary' in client.text # now we're on the modern one
721
 
    # check automatic calculating of enddate
722
 
 
723
 
    # check automatic calculating of enddate
724
 
    url = '/customers/classcard_add_modern_add_card?cuID=1&scdID=1'
725
 
    data = {'school_classcards_id' :  1,
726
 
            'Startdate'            : '2014-01-01',
727
 
            'Note'                 : 'Bananas'}
728
 
    client.post(url, data=data)
729
 
    assert client.status == 200
730
 
 
731
 
    # check db
732
 
    assert web2py.db(web2py.db.customers_classcards).count() == 1
733
 
    # check automatich adding of enddate
734
 
    assert web2py.db.customers_classcards(1).Enddate == datetime.date(2014, 3, 31)
735
 
 
736
 
    # check classcard invoice
737
 
    check_classcard_invoice(web2py)
738
 
 
739
 
 
740
 
def test_classcard_add_modern_trialcard_removed_after_getting_one(client, web2py):
741
 
    '''
742
 
        Check that the trialcard options are no longer listed
743
 
    '''
744
 
    nr_cards = 5
745
 
    populate_school_classcards(web2py, nr_cards, trialcard = True)
746
 
    populate_customers(web2py, 1)
747
 
 
748
 
    trialcard_id = nr_cards + 1
749
 
 
750
 
    web2py.db.customers_classcards.insert(
751
 
        auth_customer_id = 1001,
752
 
        school_classcards_id = trialcard_id,
753
 
        Startdate = '2014-01-01',
754
 
        Enddate = '2014-01-31',
755
 
        Note = 'Cherries' )
756
 
 
757
 
    web2py.db.commit()
758
 
    # check db
759
 
    assert web2py.db(web2py.db.customers_classcards).count() == 1
760
 
 
761
 
    # check that the trialcard isn't listed
762
 
    url = '/customers/classcard_add_modern?cuID=1001'
763
 
    client.get(url)
764
 
    assert client.status == 200
765
 
    assert not web2py.db.school_classcards(trialcard_id).Name in client.text
766
 
 
767
 
 
768
 
def test_classcard_edit(client, web2py):
769
 
    '''
770
 
        can we edit a classcard?
771
 
    '''
772
 
    nr_cards = 1
773
 
    populate_school_classcards(web2py, nr_cards, trialcard = True)
774
 
    populate_customers(web2py, 1)
775
 
 
776
 
    trialcard_id = nr_cards + 1
777
 
 
778
 
    web2py.db.customers_classcards.insert(
779
 
        auth_customer_id = 1001,
780
 
        school_classcards_id = 1,
781
 
        Startdate = '2014-01-01',
782
 
        Enddate = '2014-01-31',
783
 
        Note = 'Cherries' )
784
 
 
785
 
    web2py.db.commit()
786
 
 
787
 
    assert web2py.db(web2py.db.auth_user).count() > 0
788
 
    assert web2py.db(web2py.db.customers_classcards).count() > 0
789
 
 
790
 
    url = '/customers/classcard_edit?cuID=1001&ccdID=1'
791
 
    client.get(url)
792
 
    assert client.status == 200
793
 
 
794
 
    data = dict(id=1,
795
 
                Startdate='2016-01-01',
796
 
                Enddate='2016-02-01',
797
 
                Note='Mango smoothie')
798
 
    client.post(url, data=data)
799
 
    assert client.status == 200
800
 
 
801
 
    assert 'Class cards' in client.text # check redirection
802
 
    assert data['Startdate'] in client.text # check form submission
803
 
    assert data['Enddate'] in client.text
804
 
 
805
 
 
806
 
def test_classcard_classes_taken(client, web2py):
807
 
    '''
808
 
        Is the list of classes taken on a class card working?
809
 
        Is classes_otc applied to this list?
810
 
    '''
811
 
    populate_classes(web2py, with_otc=True)
812
 
    populate_customers_with_classcards(web2py)
813
 
 
814
 
    web2py.db.classes_attendance.insert(
815
 
        classes_id = 1,
816
 
        ClassDate = '2014-01-06',
817
 
        auth_customer_id = 1001,
818
 
        customers_classcards_id = 1,
819
 
        AttendanceType = 3
820
 
    )
821
 
 
822
 
    web2py.db.commit()
823
 
 
824
 
    url = '/customers/classcard_classes?ccID=1'
825
 
    client.get(url)
826
 
    assert client.status == 200
827
 
 
828
 
    # check classes_otc application
829
 
    location = web2py.db.school_locations(2).Name.split(' ')[0]
830
 
    assert location in client.text
831
 
 
832
 
    classtype = web2py.db.school_classtypes(2).Name.split(' ')[0]
833
 
    assert classtype in client.text
834
 
 
835
 
 
836
 
def test_classes_reservations_recurring(client, web2py):
837
 
    '''
838
 
        List reservations for a customer (this is the default)
839
 
    '''
840
 
    prepare_classes(web2py)
841
 
 
842
 
    url = '/customers/classes_reservations?cuID=1001'
843
 
    client.get(url)
844
 
    assert client.status == 200
845
 
 
846
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
847
 
    # make sure one reservation is showing
848
 
    assert client.text.count(location_name) == 1
849
 
 
850
 
 
851
 
def test_classes_reservations_filter_single(client, web2py):
852
 
    '''
853
 
        Check filter for single classes
854
 
    '''
855
 
    prepare_classes(web2py)
856
 
 
857
 
    url = '/customers/classes_reservations?cuID=1001&filter=single'
858
 
    client.get(url)
859
 
    assert client.status == 200
860
 
 
861
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
862
 
    # make sure one reservation is showing
863
 
    assert client.text.count(location_name) == 1
864
 
 
865
 
 
866
 
def test_classes_reservations_filter_trial(client, web2py):
867
 
    '''
868
 
        Check filter for trialclasses
869
 
    '''
870
 
    prepare_classes(web2py)
871
 
 
872
 
    url = '/customers/classes_reservations?cuID=1001&filter=trial'
873
 
    client.get(url)
874
 
    assert client.status == 200
875
 
 
876
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
877
 
    # make sure one reservation is showing
878
 
    assert client.text.count(location_name) == 1
879
 
 
880
 
 
881
 
def test_classes_reservation_add_list_classes_for_date(client, web2py):
882
 
    '''
883
 
        Does the listing of classes for a specified date work?
884
 
    '''
885
 
    prepare_classes(web2py)
886
 
    # we'll have to use a Monday ^ the function above only adds a class on Monday
887
 
    url = '/customers/classes_reservation_add?cuID=1001&date=2014-01-06'
888
 
    client.get(url)
889
 
    assert client.status == 200
890
 
 
891
 
    # check if we have a location and an add button
892
 
    assert 'Add' in client.text
893
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
894
 
    assert client.text.count(location_name) == 1
895
 
 
896
 
 
897
 
####
898
 
    '''
899
 
        Reservation add and edit are tested in the classes controller
900
 
    '''
901
 
####
902
 
 
903
 
 
904
 
def test_classes_waitinglist(client, web2py):
905
 
    '''
906
 
        Waitinglist for a customer
907
 
    '''
908
 
    prepare_classes(web2py)
909
 
 
910
 
    url = '/customers/classes_waitinglist?cuID=1001'
911
 
    client.get(url)
912
 
    assert client.status == 200
913
 
 
914
 
    #print web2py.db().select(web2py.db.classes_waitinglist.ALL)
915
 
 
916
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
917
 
    # make sure one reservation is showing
918
 
    assert client.text.count(location_name) == 1
919
 
 
920
 
 
921
 
def test_classes_attendance(client, web2py):
922
 
    '''
923
 
        Attendance for a customer
924
 
    '''
925
 
    prepare_classes(web2py)
926
 
 
927
 
    url = '/customers/classes_attendance?cuID=1001'
928
 
    client.get(url)
929
 
    assert client.status == 200
930
 
 
931
 
    location_name = web2py.db.school_locations(1).Name.split(' ')[0]
932
 
    # make sure one reservation is showing
933
 
    assert client.text.count(location_name) == 3
934
 
 
935
 
 
936
 
def test_payments_info_add(client, web2py):
937
 
    """
938
 
        Can we add info for a customer?
939
 
    """
940
 
    populate_customers(web2py)
941
 
    assert web2py.db(web2py.db.auth_user).count() > 0
942
 
 
943
 
    url = '/customers/payment_info_add/1001'
944
 
    client.get(url)
945
 
    assert client.status == 200
946
 
 
947
 
    data = dict(payments_methods_id='3',
948
 
                AccountNumber='123456',
949
 
                AccountHolder='Hello',
950
 
                BIC="NLBIC123",
951
 
                MandateSignatureDate='2014-01-01',
952
 
                BankName='ING',
953
 
                BankLocation='NL'
954
 
                )
955
 
    client.post(url, data=data)
956
 
    assert client.status == 200
957
 
    assert "info" in client.text # check redirection
958
 
    assert data['AccountNumber'] in client.text
959
 
 
960
 
    client.get(url) # check if we can add only once
961
 
    assert client.status == 200
962
 
    assert 'already' in client.text
963
 
 
964
 
def test_payments_info_edit(client, web2py):
965
 
    """
966
 
        Can we edit info for a customer?
967
 
    """
968
 
    populate_customers(web2py, 1)
969
 
 
970
 
    # get a random url to make sure the setup function runs to populate the
971
 
    # payment_methods table
972
 
    url = '/customers/index'
973
 
    client.get(url)
974
 
    assert client.status == 200
975
 
 
976
 
    web2py.db.customers_payment_info.insert(auth_customer_id   = 1001,
977
 
                                            payment_methods_id = 3)
978
 
    web2py.db.commit()
979
 
    assert web2py.db(web2py.db.auth_user).count() > 0
980
 
    assert web2py.db(web2py.db.customers_payment_info).count() == 1
981
 
 
982
 
    url = '/customers/payment_info_edit/1001/1'
983
 
 
984
 
    client.get(url)
985
 
    assert client.status == 200
986
 
 
987
 
    data = dict(id                 = 1,
988
 
                auth_customer_id   = 1001,
989
 
                payment_methods_id='3',
990
 
                AccountNumber='123456',
991
 
                AccountHolder='Hello',
992
 
                BIC="NLBIC123",
993
 
                MandateSignatureDate='2014-01-01',
994
 
                BankName='ING',
995
 
                BankLocation='NL'
996
 
                )
997
 
    client.post(url, data=data)
998
 
    assert client.status == 200
999
 
    assert "info" in client.text # check redirection
1000
 
    assert data['AccountNumber'] in client.text
1001
 
 
1002
 
 
1003
 
def test_payments_ap_add(client, web2py):
1004
 
    """
1005
 
        Can we add an alternative payment?
1006
 
    """
1007
 
    today = datetime.date.today()
1008
 
    populate_customers(web2py, 1)
1009
 
    assert web2py.db(web2py.db.auth_user).count() == 1
1010
 
 
1011
 
    url = '/customers/alternativepayment_add/1001'
1012
 
    client.get(url)
1013
 
    assert client.status == 200
1014
 
 
1015
 
    assert 'value="' + unicode(today.year) + '"' in client.text # check default year value
1016
 
    assert 'selected="selected" value="' + unicode(today.month) + '"' in client.text # check default month value
1017
 
 
1018
 
    data = dict(PaymentYear=today.year,
1019
 
                PaymentMonth=today.month,
1020
 
                Amount='99999',
1021
 
                )
1022
 
    client.post(url, data=data)
1023
 
    assert client.status == 200
1024
 
    assert "info" in client.text # check redirection
1025
 
    assert data['Amount'] in client.text
1026
 
 
1027
 
def test_payments_ap_edit(client, web2py):
1028
 
    """
1029
 
        Can we edit an alternative payment?
1030
 
    """
1031
 
    populate_customers(web2py, 1)
1032
 
    populate(web2py.db.payment_categories, 4)
1033
 
    populate(web2py.db.alternativepayments, 1)
1034
 
    assert web2py.db(web2py.db.auth_user).count() == 1
1035
 
    assert web2py.db(web2py.db.alternativepayments).count() > 0
1036
 
 
1037
 
    url = '/customers/alternativepayment_edit/1001/1'
1038
 
    client.get(url)
1039
 
    assert client.status == 200
1040
 
 
1041
 
    data = dict(PaymentYear='2015',
1042
 
                PaymentMonth='1',
1043
 
                Amount='99999',
1044
 
                )
1045
 
    client.post(url, data=data)
1046
 
    assert client.status == 200
1047
 
    assert "info" in client.text # check redirection
1048
 
    assert data['Amount'] in client.text
1049
 
 
1050
 
 
1051
 
def test_documents(client, web2py):
1052
 
    '''
1053
 
        Can we get a list of the documents available?
1054
 
    '''
1055
 
    populate_customers(web2py, 1)
1056
 
    assert web2py.db(web2py.db.auth_user).count() == 1
1057
 
 
1058
 
    url = '/customers/documents?cuID=1001'
1059
 
    client.get(url)
1060
 
    assert client.status == 200
1061
 
    assert "Documents" in client.text
1062
 
 
1063
 
 
1064
 
def test_notes(client, web2py):
1065
 
    '''
1066
 
        Can we get a list of notes and add a new note?
1067
 
    '''
1068
 
    populate_customers(web2py, 1)
1069
 
    assert web2py.db(web2py.db.auth_user).count() == 1
1070
 
 
1071
 
    # check list
1072
 
    url = '/customers/notes?cuID=1001'
1073
 
    client.get(url)
1074
 
    assert client.status == 200
1075
 
 
1076
 
    # check add
1077
 
    data = dict(Note='Bananas',
1078
 
                Alert='on')
1079
 
    client.post(url, data=data)
1080
 
    assert client.status == 200
1081
 
    assert "Add a new note" in client.text # check if we're at the notes page
1082
 
    assert data['Note'] in client.text
1083
 
 
1084
 
    # check delete
1085
 
    url = '/customers/note_delete.json'
1086
 
 
1087
 
    data = dict(id='1')
1088
 
    client.post(url, data=data)
1089
 
    assert client.status == 200
1090
 
 
1091
 
    assert web2py.db(web2py.db.customers_notes).count() == 0
1092
 
 
1093
 
 
1094
 
def test_workshops(client, web2py):
1095
 
    '''
1096
 
        Test display of workshops
1097
 
    '''
1098
 
    populate_workshops_products_customers(web2py)
1099
 
 
1100
 
    url = '/customers/workshops?cuID=1001'
1101
 
    client.get(url)
1102
 
    assert client.status == 200
1103
 
 
1104
 
    workshop = web2py.db.workshops(1)
1105
 
    assert workshop.Name.split(' ')[0] in client.text
1106
 
    # check label (product 2 is defined for cuID 1 in populate function)
1107
 
    product = web2py.db.workshops_products(2)
1108
 
    assert product.Name.split(' ')[0] in client.text
1109
 
    # check payment and info form
1110
 
    assert 'Workshop Info' in client.text
1111
 
 
1112
 
 
1113
 
def test_workshops_add(client, web2py):
1114
 
    '''
1115
 
        Is the list of workshops showing?
1116
 
    '''
1117
 
    populate_workshops_products_customers(web2py)
1118
 
 
1119
 
    url = '/customers/workshops_add?cuID=1001'
1120
 
    client.get(url)
1121
 
    assert client.status == 200
1122
 
 
1123
 
    # check that the workshop is listed
1124
 
    workshop = web2py.db.workshops(1)
1125
 
    assert workshop.Name.split(' ')[0] in client.text
1126
 
    # assert that the products button is showing
1127
 
    assert 'Products' in client.text
1128
 
 
1129
 
 
1130
 
def test_workshop_add_list_products(client, web2py):
1131
 
    '''
1132
 
        Is the list of workshop products showing from a customer?
1133
 
    '''
1134
 
    populate_workshops_products_customers(web2py)
1135
 
 
1136
 
    url = '/customers/workshops_add_list_products?cuID=1001&wsID=1'
1137
 
    client.get(url)
1138
 
    assert client.status == 200
1139
 
 
1140
 
    # check if the name of the workshop is showing
1141
 
    workshop = web2py.db.workshops(1)
1142
 
    assert workshop.Name.split(' ')[0] in client.text
1143
 
 
1144
 
    # check if the add button is showing
1145
 
    assert 'Add' in client.text
1146
 
    assert 'waitinglist' in client.text
1147
 
 
1148
 
 
1149
 
# def test_load_list_sell_workshop_product(client, web2py):
1150
 
#     '''
1151
 
#         Test if the list shows
1152
 
#     '''
1153
 
#     populate_workshops_products_customers(web2py)
1154
 
#
1155
 
#     url = '/customers/load_list?list_type=workshops_products_sell&wsID=1&wspID=1'
1156
 
#     client.get(url)
1157
 
#     assert client.status == 200
1158
 
#
1159
 
#     customer = web2py.db.auth_user(1001)
1160
 
#     assert customer.first_name in client.text
1161
 
 
1162
 
 
1163
 
def test_payment_info_dutch_iban_validator_length_fail(client, web2py):
1164
 
    '''
1165
 
        Checks if the validator fails when the length of the number is too short
1166
 
    '''
1167
 
    # by getting some page the payment methods get initialized
1168
 
    url = '/default/user/login'
1169
 
    client.get(url)
1170
 
    assert client.status == 200
1171
 
 
1172
 
    populate_customers(web2py, 1)
1173
 
    populate_customers_payment_info(web2py, 1)
1174
 
 
1175
 
    url = '/customers/payment_info_edit/1001/1'
1176
 
    client.get(url)
1177
 
    assert client.status == 200
1178
 
 
1179
 
    data = {'id'            : 1,
1180
 
            'AccountNumber' : 'NL21INGB012345678'} # 1 digit too short for valid Dutch IBAN
1181
 
    client.post(url, data=data)
1182
 
    assert client.status == 200
1183
 
 
1184
 
    assert 'Dutch IBAN should be 18 characters' in client.text
1185
 
 
1186
 
 
1187
 
def test_payment_info_dutch_iban_validator_validation_fail(client, web2py):
1188
 
    '''
1189
 
        Checks if the validator fails when the IBAN isn't valid
1190
 
    '''
1191
 
    # by getting some page the payment methods get initialized
1192
 
    url = '/default/user/login'
1193
 
    client.get(url)
1194
 
    assert client.status == 200
1195
 
 
1196
 
    populate_customers(web2py, 1)
1197
 
    populate_customers_payment_info(web2py, 1)
1198
 
 
1199
 
    url = '/customers/payment_info_edit/1001/1'
1200
 
    client.get(url)
1201
 
    assert client.status == 200
1202
 
 
1203
 
    data = {'id'            : 1,
1204
 
            'AccountNumber' : 'NL21INGB0123456789'} # Invalid Dutch IBAN
1205
 
    client.post(url, data=data)
1206
 
    assert client.status == 200
1207
 
 
1208
 
    assert 'IBAN validation failed' in client.text
1209
 
 
1210
 
 
1211
 
def test_payment_info_dutch_iban_validator_pass(client, web2py):
1212
 
    '''
1213
 
        Checks if the validator passes on a correct number
1214
 
    '''
1215
 
    # by getting some page the payment methods get initialized
1216
 
    url = '/default/user/login'
1217
 
    client.get(url)
1218
 
    assert client.status == 200
1219
 
 
1220
 
    populate_customers(web2py, 1)
1221
 
    populate_customers_payment_info(web2py, 1)
1222
 
 
1223
 
    url = '/customers/payment_info_edit/1001/1'
1224
 
    client.get(url)
1225
 
    assert client.status == 200
1226
 
 
1227
 
    data = {'id'            : 1,
1228
 
            'AccountNumber' : 'NL89TRIO0390502103'} # Valid Dutch IBAN
1229
 
    client.post(url, data=data)
1230
 
    assert client.status == 200
1231
 
 
1232
 
    # verify redirection
1233
 
    assert 'Payment info' in client.text
1234
 
 
1235
 
    # verify database
1236
 
    row = web2py.db.customers_payment_info(1)
1237
 
    assert row.AccountNumber == data['AccountNumber']
1238
 
 
1239
 
 
1240
 
def test_payment_info_not_iban_pass(client, web2py):
1241
 
    '''
1242
 
        Checks if the validator passes when something other than a dutch IBAN nr is added
1243
 
    '''
1244
 
    # by getting some page the payment methods get initialized
1245
 
    url = '/default/user/login'
1246
 
    client.get(url)
1247
 
    assert client.status == 200
1248
 
 
1249
 
    populate_customers(web2py, 1)
1250
 
    populate_customers_payment_info(web2py, 1)
1251
 
 
1252
 
    url = '/customers/payment_info_edit/1001/1'
1253
 
    client.get(url)
1254
 
    assert client.status == 200
1255
 
 
1256
 
    data = {'id'            : 1,
1257
 
            'AccountNumber' : '12445565ef39i65'} # Random stuff
1258
 
    client.post(url, data=data)
1259
 
    assert client.status == 200
1260
 
 
1261
 
    # verify redirection
1262
 
    assert 'Payment info' in client.text
1263
 
 
1264
 
    # verify database
1265
 
    row = web2py.db.customers_payment_info(1)
1266
 
    assert row.AccountNumber == data['AccountNumber'].upper()