Coverage for test/use_case/test_extractia.py: 60%

62 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2026-02-10 01:10 +0100

1# first test extractia 

2 

3 

4 

5 

6def test_extractia_anon(): 

7 from lib.stockage.lib_pg_safia_sys import LibPGSafiaSys 

8 from test.main_test import lpgss_singleton, project_nrt 

9 

10 from lib.batch.lib_batch import run_batch_datou 

11 mtr_datou_id = 25 

12 safia_project_id = project_nrt 

13 verbose = False 

14 from uuid import uuid4 

15 safia_doc_id = "log_loop_nrt_" + str(uuid4()) + "_log_loop_nrt" 

16 with_audit = True 

17 limit =1 

18 offset = 0 

19 in_file = "test/io/input_dossier_vr_misc_020224.pdf" 

20 out_folder = "test/data/output" 

21 output = "anon_pdf:anon_pdf" 

22 input = "in_file:in_file" 

23 

24 ret = run_batch_datou(mtr_datou_id, safia_project_id, safia_doc_id, input, output, 

25 verbose, with_audit, 

26 lpgss_singleton, in_file=in_file, nb_lines=limit, offset=offset, out_folder=out_folder) 

27 

28 assert ret != None 

29 

30def test_extractia(): 

31 from lib.stockage.lib_pg_safia_sys import LibPGSafiaSys 

32 from test.main_test import lpgss_singleton, project_nrt 

33 

34 from lib.batch.lib_batch import run_batch_datou 

35 mtr_datou_id = 40 # 20 

36 safia_project_id = project_nrt 

37 verbose = False 

38 from uuid import uuid4 

39 safia_doc_id = "log_loop_nrt_" + str(uuid4()) + "_log_loop_nrt" 

40 with_audit = True 

41 limit =1 

42 offset = 0 

43 in_file = "test/io/input_dossier_vr_misc_020224.pdf" 

44 out_folder = "test/data/output" 

45 output = "" # todo a compléter 

46 input = "in_file:in_file" 

47 

48 ret = run_batch_datou(mtr_datou_id, safia_project_id, safia_doc_id, input, output, 

49 verbose, with_audit, 

50 lpgss_singleton, in_file=in_file, nb_lines=limit, offset=offset, out_folder=out_folder) 

51 

52 assert ret != None 

53 

54 

55 

56def te_st_saxia_anon_local(): 

57 from lib.stockage.lib_pg_safia_sys import LibPGSafiaSys 

58 from test.main_test import lpgss_singleton, project_nrt 

59 

60 from lib.batch.lib_batch import run_batch_datou, create_pandas_table_from_text 

61 mtr_datou_id = 45 # VR 6/2/26 : il faudrait installer BERT et que ca marche, mais de toute facon il faut utliser des VLMs à présent 

62# mtr_datou_id = 25 

63 safia_project_id = project_nrt 

64 verbose = False 

65 from uuid import uuid4 

66 safia_doc_id = "log_loop_nrt_" + str(uuid4()) + "_log_loop_nrt" 

67 with_audit = True 

68 limit =1 

69 offset = 0 

70 in_file = "test/io/input_dossier_vr_misc_020224.pdf" 

71# in_file = "test/use_case/data/pseudo/extract_from_id_2_d_20240222.pdf" 

72 in_file = "test/use_case/data/pseudo/d_20240108_id_7_nb_6_modif.pdf" 

73 in_file = "test/use_case/data/pseudo/extract_d_20240108_id_7_nb_6_modif.pdf" 

74 out_folder = "test/data/output" 

75 output = "anon_pdf:anon_pdf,PERS:PERS,genre:genre,nom:nom,prenom:prenom,date_naissance:date_naissance,adresse:adresse,adresse_mail:adresse_mail,telephone:telephone,numero_secu:numero_secu" 

76 input = "in_file:in_file" 

77 

78 ret = run_batch_datou(mtr_datou_id, safia_project_id, safia_doc_id, input, output, 

79 verbose, with_audit, 

80 lpgss_singleton, in_file=in_file, nb_lines=limit, offset=offset, out_folder=out_folder) 

81 

82 assert ret != None 

83 

84 total_content = ret["json_to_save"][0]["text"] if "json_to_save" in ret and len(ret["json_to_save"]) > 0 and "text" in ret["json_to_save"][0] else "" 

85 df = create_pandas_table_from_text(total_content) 

86 pers_first_value = df["PERS"][0] 

87 pers_first_value_non_reg = 'Begin;Cisile REGNIER;Gaulle;BONET;Louise ee;Docteur ABITBOL;Mime Henry;Ganlie;Begin;antoine Lacacsagne CeNtre Antoine - Lacassagne;E. BARRANGER' 

88 assert pers_first_value == pers_first_value_non_reg 

89 

90 print("Test finished and should be in sucess if this is printed") 

91 

92 

93