File: test_api.py

package info (click to toggle)
wimsapi 0.5.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: python: 3,096; makefile: 16
file content (680 lines) | stat: -rw-r--r-- 24,862 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
import os
import unittest
from io import BytesIO
from tarfile import TarError, TarFile

from wimsapi.api import WimsAPI


WIMS_URL = os.getenv("WIMS_URL") or "http://localhost:7777/wims/wims.cgi/"

CSV = """login,password,name,lastname,firstname,email,regnum
desc,desc,desc,desc,desc,desc,desc
jdoe,password,Jhon Doe,Doe,Jhon,jhon@email.fr,1
qcoumes,password,Quentin Coumes,Coumes,Quentin,quentin@mail.fr,2"""



class WimsAPITestCase(unittest.TestCase):
    
    @classmethod
    def setUpClass(cls):
        """Remove class potentially created by tests"""
        api = WimsAPI(WIMS_URL, "myself", "toto")
        api.delclass(999999, "myclass")
        api.delclass(999666, "myclass")
        api.delclass(999990, "myclass")
    
    
    def test_init_and_properties(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        self.assertEqual(api.url, WIMS_URL)
        self.assertEqual(api.ident, "myself")
        self.assertEqual(api.passwd, "toto")
    
    
    def test_0_addclass_id(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addclass(
            "myclass",
            {
                'description': "Test class",
                "institution": "Test institution",
                "supervisor":  "Test supervisor",
                "email":       "Test@mail.com",
                "password":    "password",
                "lang":        "fr",
                "limit":       500
            },
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            },
            999999
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "class 999999 correctly added")
        self.assertEqual(response['class_id'], "999999")
    
    
    def test_0_addclass_random(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addclass(
            "myclass",
            {
                'description': "Test class",
                "institution": "Test institution",
                "supervisor":  "Test supervisor",
                "email":       "Test@mail.com",
                "password":    "password",
                "lang":        "fr",
                "limit":       500
            },
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            },
        )
        self.assertTrue(status)
        self.assertIn('class_id', response)
        class_id = response['class_id']
        self.assertEqual(response['message'], "class %s correctly added" % class_id)
        status, response = api.delclass(class_id, "myclass")
        if not status:
            self.fail("Could not delete class of id %s. This class must be deleted before testing."
                      % class_id)
    
    
    def test_addexam(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addexam(999999, "myclass", {})
        self.assertTrue(status)
        self.assertEqual(response['message'], "exam #1 correctly added")
    
    
    def test_addexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addexo(999999, "myclass", 1, r"\text{ a = \ma_matrice[1;] } ", True)
        self.assertTrue(status)
        self.assertEqual(response['message'], "exercice 1 successfully added")
    
    
    def test_addsheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addsheet(999999, "myclass", {})
        self.assertTrue(status)
    
    
    def test_adduser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.adduser(
            999999,
            "myclass",
            "jdoe",
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            }
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "user jdoe correctly added")
    
    
    def test_authuser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.authuser(999999, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertTrue('wims_session' in response)
    
    
    def test_authuser_hash(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.authuser(999999, "myclass", "supervisor", "SHA1")
        self.assertTrue(status)
        self.assertTrue('wims_session' in response)
    
    
    def test_buildexos(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.buildexos(999999, "myclass")
        self.assertFalse(status)
        self.assertEqual(response['message'], "COMPILATION ERROR No statement defined.")
    
    
    def test_checkclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.checkclass(999999, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['message'], "Class exists")
    
    
    def test_checkexam(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.checkexam(999999, "myclass", 1)
        self.assertTrue(status)
        self.assertEqual(response['message'], "exam 1 exists")
    
    
    def test_checkident(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.checkident()
        self.assertTrue(status)
        self.assertEqual(response['message'], "Connection accepted")
    
    
    def test_checksheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.checksheet(999999, "myclass", 1)
        self.assertTrue(status)
        self.assertEqual(response['message'], "sheet 1 exists")
    
    
    def test_checkuser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.checkuser(999999, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertEqual(response['message'], 'user supervisor exists')
    
    
    def test_cleanclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.cleanclass(999999, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['message'], 'class 999999 correctly cleaned')
    
    
    def test_copyclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.copyclass(999999, "myclass")
        self.assertTrue(status)
        self.assertIn('new_class', response)
        api.delclass(response['new_class'], "myclass")
    
    
    def test_delclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addclass(
            "myclass",
            {
                'description': "Test class",
                "institution": "Test institution",
                "supervisor":  "Test supervisor",
                "email":       "Test@mail.com",
                "password":    "password",
                "lang":        "fr"
            },
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            },
            999666
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "class 999666 correctly added")
        
        status, response = api.delclass(999666, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['message'], "class 999666 correctly deleted")
    
    
    def test_delexam(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addexam(999999, "myclass", {})
        self.assertTrue(status)
        self.assertEqual(response['message'], "exam #2 correctly added")
        
        status, response = api.delexam(999999, "myclass", 2)
        self.assertTrue(status)
        self.assertEqual(response['message'], "Exam #2 of class 999999 correctly deleted")
    
    
    def test_delexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.delexo(999999, "myclass", 1)
        self.assertFalse(status)
        self.assertEqual(response['message'], "1 NOT exists in this Class !")
    
    
    def test_delsheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addsheet(999999, "myclass", {})
        self.assertTrue(status)
        
        status, response = api.delsheet(999999, "myclass", 2)
        self.assertTrue(status)
        self.assertEqual(response['message'], "sheet #2 of class 999999 correctly deleted")
    
    
    def test_deluser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.adduser(
            999999,
            "myclass",
            "jdoe2",
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            }
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "user jdoe2 correctly added")
        
        status, response = api.deluser(999999, "myclass", "jdoe2")
        self.assertTrue(status)
        self.assertEqual(response['message'], "User jdoe2 moved to trash.")
    
    
    def test_getclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclass(9001, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['description'], 'Aide au d veloppement de ressources.')
    
    
    def test_getclass_options(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclass(9001, "myclass", ["password"])
        self.assertTrue(status)
        self.assertIn("password", response)
    
    
    def test_getclassesuser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclassesuser("myclass", "supervisor")
        self.assertTrue(status)
        self.assertEqual(response['classes_list'], [{'qclass': '999999'}])
    
    
    def test_getclassfile(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclassfile(999999, "myclass", '.log')
        self.assertTrue(status)
        self.assertEqual(response[34:49], b"User jdoe creat")
    
    
    def test_getclassmodif(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclassmodif(999999, "myclass", '19700101')
        self.assertTrue(status)
        self.assertEqual(response['since_date'], '197001010000')
        self.assertEqual(len(response['modifs']), 19)
    
    
    def test_getclasstgz(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getclasstgz(999999, "myclass")
        self.assertTrue(status)
        
        try:
            TarFile.open(fileobj=BytesIO(response), mode="r:gz")
        except TarError as e:
            self.fail("Response was not a valid tgz :\n" + str(e))
    
    
    def test_getcsv(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getcsv(9001, "myclass", ["login", "password", "name", "email"])
        self.assertTrue(status)
        self.assertEqual(type(response), bytes)
    
    
    def test_getexam(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getexam(999999, "myclass", 1)
        self.assertTrue(status)
        self.assertEqual(response['exam_title'], "Examen #1")
    
    
    def test_getexamlog(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getexamlog(999999, "myclass", "supervisor", 1)
        self.assertFalse(status)
        self.assertEqual(response['message'],
                         "the user supervisor hasn't any exam log in this class.")
    
    
    def test_getexamscores(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getexamscores(999999, "myclass", 1)
        self.assertFalse(status)
        self.assertEqual(response['message'], "Exam #1 must be active")
    
    
    def test_getexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getexo(9001, "myclass", 3, 1)
        self.assertTrue(status)
        self.assertEqual(response['exo_title'], "Choice 1")
    
    
    def test_getexofile(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getexofile(9001, "myclass", 1)
        self.assertTrue(status)
        self.assertEqual(response,
                         b'\\title{Un pr\xe9}\n\\language{fr}\n\\author{Sophie Lemaire}\n\\email{'
                         b'soph'
                         b'ie.lemaire@math.u-psud.fr}\n\\computeanswer{no}\n\\precision{'
                         b'10000}\n\n\\in'
                         b'teger{L = 10*randint(1..10)}\n\\integer{l = 10*randint('
                         b'1..10)}\n\\integer{pe'
                         b"r = 2*(\\L+\\l)}\n\n\\statement{Donner le p\xe9rim\xe8tre d'un pr\xe9 "
                         b"rect"
                         b'angulaire\n de longueur \\L m et de largeur \\l m.}\n\n\\answer{'
                         b'p\xe9rim\xe8'
                         b'tre (en m)}{\\per}{type=numeric}\n')
    
    
    def test_getinfoserver(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getinfoserver()
        self.assertTrue(status)
        self.assertIn("server_version", response)
    
    
    def test_getlog(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getlog(9001, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertIn("user_log", response)
    
    
    def test_getmodule(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getmodule('E1/geometry/oefsquare.fr')
        self.assertTrue(status)
        self.assertEqual(response['title'], "OEF Dessins")
    
    
    def test_getscore(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getscore(9001, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertEqual(response['exam_scores'], [[]])
    
    
    def test_getscore_sheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getscore(9001, "myclass", "supervisor", 1)
        self.assertTrue(status)
        self.assertEqual(response['exam_scores'], [[]])
    
    
    def test_getscores(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getscores(9001, "myclass", ["login", "password", "name", "email"])
        self.assertTrue(status)
        self.assertEqual(type(response), bytes)
    
    
    @unittest.skip("Job not defined in wims yet")
    def test_getsession(self):  # pragma: no cover
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getsession()
        self.assertTrue(status)
        self.assertTrue(False)
    
    
    def test_getsheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getsheet(9001, "myclass", 3)
        self.assertTrue(status)
        self.assertEqual(response['sheet_title'], "Syntaxe des exercices OEF à réponse prédéfinie")
    
    
    def test_getsheetscores(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getsheetscores(9001, "myclass", 3, verbose=True)
        self.assertTrue(status)
        self.assertIn('data_scores', response)
    
    
    def test_getsheetstats(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getsheetstats(9001, "myclass", 3)
        self.assertTrue(status)
        self.assertIn("sheet_got_details", response)
    
    
    def test_gettime(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.gettime()
        self.assertTrue(status)
        self.assertIn("server_time", response)
    
    
    def test_getuser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.getuser(9001, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertEqual(response['firstname'], 'Sophie')
    
    
    def test_lightpopup(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.authuser(999999, "myclass", "supervisor")
        self.assertTrue(status)
        self.assertTrue('wims_session' in response)
        
        session = response['wims_session']
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.lightpopup(9001, "myclass", "supervisor", session,
                                          "H3/analysis/oeflinf.fr")
        self.assertTrue(status)
        self.assertIn(b'The exercises will be randomly selected fr'
                      b'om your selection \n(or otherwise from among all the available exercises '
                      b'if you didn\'t select any).', response)
    
    
    def test_linkexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.linkexo(999999, "myclass", 1, 1, 1)
        self.assertFalse(status)
        self.assertEqual(response["message"], "sheet 1 must be active")
    
    
    def test_linksheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.linksheet(999999, "myclass", 1, 1)
        self.assertFalse(status)
        self.assertEqual(response["message"], "sheet 1 must be active")
    
    
    def test_listclasses(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listclasses("myclass")
        self.assertTrue(status)
        self.assertEqual(response["classes_list"], [{'qclass': '999999'}])
    
    
    def test_listexams(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listexams(9001, "myclass")
        self.assertTrue(status)
        self.assertEqual(response["nbexam"], '0')
    
    
    def test_listexos(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listexos(9001, "myclass")
        self.assertTrue(status)
        self.assertGreaterEqual(response["exocount"], 114)
    
    
    def test_listlinks(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listlinks(9001, "myclass", 1, 1)
        self.assertFalse(status)
        self.assertEqual(response["message"],
                         "element #1 of type exam does not exist in this class (9001)")
    
    
    def test_listmodules(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listmodules("H1")
        self.assertTrue(status)
        self.assertEqual(response["title"], 'Middle school year 1')
    
    
    def test_listsheets(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.listsheets(9001, "myclass")
        self.assertTrue(status)
        self.assertGreaterEqual(response["nbsheet"], "11")
    
    
    def test_modclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.modclass(999999, "myclass", {'description': "New title"})
        self.assertTrue(status)
        self.assertEqual(response["message"], 'Modifications done')
    
    
    def test_modexam(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.modexam(999999, "myclass", 1, {'title': "New title"})
        self.assertTrue(status)
        self.assertEqual(response["message"], '1 modifications done on exam 1.')
    
    
    def test_modsheet(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.modsheet(999999, "myclass", 1, {'title': "New title"})
        self.assertTrue(status)
        self.assertEqual(response["message"], '1 modifications done on sheet 1.')
    
    
    def test_moduser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.moduser(999999, "myclass", "supervisor", {'firstname': "Newname"})
        self.assertTrue(status)
        self.assertEqual(response["message"], 'Modifications done')
    
    
    def test_movexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.movexo(9001, 999999, "myclass", 2, True)
        self.assertFalse(status)
        self.assertEqual(response["message"], 'COMPILATION ERROR No statement defined.')
        
        status, response = api.movexo(9001, 999999, "myclass", 3)
        self.assertFalse(status)
        self.assertEqual(response["message"], 'COMPILATION ERROR No statement defined.')
    
    
    def test_movexos(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.movexos(9001, 999999, "myclass", True)
        self.assertTrue(status)
        self.assertEqual(response["message"], 'exercices successfully copied')
        
        status, response = api.movexos(9001, 999999, "myclass")
        self.assertTrue(status)
        self.assertEqual(response["message"], 'exercices successfully moved')
    
    
    @unittest.skip("Job not defined in wims yet")
    def test_putcsv(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.putcsv(999999, "myclass", CSV, False)
        self.assertTrue(status)
        self.assertEqual(response["message"], 'exercices successfully copied')
    
    
    def test_putexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.putexo(999999, "myclass", 1, "H3/analysis/oeflinf.fr", {
            "exo":        "fnctlin1", "qnum": "1",
            "scoredelay": "20,50",
            "seedrepeat": "2", "qcmlevel": "1"
        })
        self.assertTrue(status)
        self.assertEqual(response["message"], 'exercice correctly added in sheet #1')
    
    
    def test_recuser(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.adduser(
            999999,
            "myclass",
            "jdoe3",
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            }
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "user jdoe3 correctly added")
        
        status, response = api.deluser(999999, "myclass", "jdoe3")
        self.assertTrue(status)
        self.assertEqual(response['message'], "User jdoe3 moved to trash.")
        
        status, response = api.recuser(999999, "myclass", "jdoe3")
        self.assertTrue(status)
        self.assertEqual(response['message'], "User successfully recovered")
    
    
    def test_repairclass(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.repairclass(999999, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['action'], "checkonly")
    
    
    def test_sharecontent(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.addclass(
            "myclass",
            {
                'description': "Test class",
                "institution": "Test institution",
                "supervisor":  "Test supervisor",
                "email":       "Test@mail.com",
                "password":    "password",
                "lang":        "fr",
                "limit":       500
            },
            {
                "lastname":  "Doe",
                "firstname": "Jhon",
                "password":  "password"
            },
            999990
        )
        self.assertTrue(status)
        self.assertEqual(response['message'], "class 999990 correctly added")
        
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.sharecontent(9001, 999990, "myclass")
        self.assertTrue(status)
        self.assertEqual(response['message'], 'content successfully shared')
    
    
    def test_testexo(self):
        api = WimsAPI(WIMS_URL, "myself", "toto")
        status, response = api.testexo(
            b'\\title{Un pr\xe9}\n\\language{fr}\n\\author{Sophie Lemaire}\n\\email{'
            b'soph'
            b'ie.lemaire@math.u-psud.fr}\n\\computeanswer{no}\n\\precision{'
            b'10000}\n\n\\in'
            b'teger{L = 10*randint(1..10)}\n\\integer{l = 10*randint('
            b'1..10)}\n\\integer{pe'
            b"r = 2*(\\L+\\l)}\n\n\\statement{Donner le p\xe9rim\xe8tre d'un pr\xe9 "
            b"rect"
            b'angulaire\n de longueur \\L m et de largeur \\l m.}\n\n\\answer{'
            b'p\xe9rim\xe8'
            b'tre (en m)}{\\per}{type=numeric}\n')
        self.assertTrue(status)
        self.assertEqual(response['compilation_result'], "submit.oef.. -> submit.def")



if __name__ == '__main__':
    unittest.main()