@@ -32,6 +32,7 @@ def setUp(self):
3232 self .database = get_db ()
3333 self .app = app .test_client ()
3434 self .token = get_token ('admin' )
35+ warnings .filterwarnings ('ignore' , category = UserWarning )
3536 warnings .filterwarnings ('ignore' , category = ResourceWarning )
3637
3738 def create_supplier (self ):
@@ -87,15 +88,16 @@ def test_successful_upload_file(self):
8788
8889 self .database .execute ("SELECT * FROM documents" )
8990 document = self .database .fetchall ()
91+
9092 self .assertEqual (supplier .json ['id' ], document [0 ]['supplier_id' ])
9193 self .assertEqual (408.50 , float (document [0 ]['datas' ]['total_vat' ]))
9294 self .assertEqual (2042.5 , float (document [0 ]['datas' ]['total_ht' ]))
9395 self .assertEqual (408.50 , float (document [0 ]['datas' ]['vat_amount' ]))
9496 self .assertEqual (2451.0 , float (document [0 ]['datas' ]['total_ttc' ]))
95- self .assertEqual ("15/12/ 2016" , document [0 ]['datas' ]['document_date' ])
97+ self .assertEqual ("2016-12-15 " , document [0 ]['datas' ]['document_date' ])
9698 self .assertEqual ("INV-001510" , document [0 ]['datas' ]['invoice_number' ])
9799 self .assertEqual (2042.5 , float (document [0 ]['datas' ]['no_rate_amount' ]))
98- self .assertEqual ("14/01/ 2017" , document [0 ]['datas' ]['document_due_date' ])
100+ self .assertEqual ("2017-01-14 " , document [0 ]['datas' ]['document_due_date' ])
99101 self .assertEqual ("AM161941219-1607" , document [0 ]['datas' ]['quotation_number' ])
100102 self .assertEqual (200 , document_res .status_code )
101103
@@ -332,7 +334,8 @@ def test_successful_export_xml(self):
332334 json = {'args' : output [0 ]},
333335 headers = {"Content-Type" : "application/json" , 'Authorization' : 'Bearer ' + self .token })
334336 self .assertEqual (200 , response .status_code )
335- self .assertTrue (os .path .isfile (f'/var/share/{ CUSTOM_ID } /export/verifier/INV-001510_F_15-12-2016_FR04493811251.xml' ))
337+ filename = response .json
338+ self .assertTrue (os .path .isfile (f'{ filename } ' ))
336339
337340 def test_successful_export_pdf (self ):
338341 self .create_supplier ()
@@ -345,7 +348,8 @@ def test_successful_export_pdf(self):
345348 json = {'args' : output [0 ]},
346349 headers = {"Content-Type" : "application/json" , 'Authorization' : 'Bearer ' + self .token })
347350 self .assertEqual (200 , response .status_code )
348- self .assertTrue (os .path .isfile (f'/var/share/{ CUSTOM_ID } /export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf' ))
351+ filename = response .json
352+ self .assertTrue (os .path .isfile (f'{ filename } ' ))
349353
350354 def test_successful_export_facturx (self ):
351355 self .create_supplier ()
@@ -357,15 +361,15 @@ def test_successful_export_facturx(self):
357361 response = self .app .post (f'/{ CUSTOM_ID } /ws/verifier/documents/' + str (document [0 ]['id' ]) + '/export_facturx' ,
358362 json = {'args' : output [0 ]},
359363 headers = {"Content-Type" : "application/json" , 'Authorization' : 'Bearer ' + self .token })
360-
364+ filename = response . json
361365 is_facturx = False
362- with open (f'/var/share/ { CUSTOM_ID } /export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf ' , 'rb' ) as f :
366+ with open (f'{ filename } ' , 'rb' ) as f :
363367 _ , _xml_content = facturx .get_facturx_xml_from_pdf (f .read ())
364368 if _ is not None :
365369 is_facturx = True
366370
367371 self .assertEqual (200 , response .status_code )
368- self .assertTrue (os .path .isfile (f'/var/share/ { CUSTOM_ID } /export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf ' ))
372+ self .assertTrue (os .path .isfile (f'{ filename } ' ))
369373 self .assertTrue (is_facturx )
370374
371375 def tearDown (self ) -> None :
0 commit comments