Beispiel #1
0
 def test_01_FiltrosOVR_temtg(self):
     setor1 = Setor()
     setor1.id = 567567
     setor1.nome = 'Setor 567'
     session.add(setor1)
     ovr1 = self.create_OVR_campos('R1', 'U1', 'C1', '2020-05-01', 'teste1',
                                   setor1)
     try:
         session.refresh(ovr1)
         ovrs = get_ovr_filtro(session, {})
         assert isinstance(ovrs, list)
         assert len(ovrs) == 1
         ovrs = get_ovr_filtro(session, {'temtg': True})
         assert isinstance(ovrs, list)
         assert len(ovrs) == 0
         tgovr = TGOVR()
         tgovr.qtde = 10
         tgovr.valor = 100
         tgovr.afrfb = ovr1.user_name
         tgovr.numerolote = '1234'
         tgovr.descricao = 'nonono'
         tgovr.ovr_id = ovr1.id
         session.add(tgovr)
         session.commit()
         ovrs = get_ovr_filtro(session, {'temtg': True})
         assert isinstance(ovrs, list)
         assert len(ovrs) == 1
     finally:
         session.delete(tgovr)
         session.delete(ovr1)
         session.commit()
Beispiel #2
0
 def test_OVR_Evento(self):
     ovr = self.create_OVR_valido()
     session.refresh(ovr)
     tg = TGOVR()
     tg.descricao = 'teste10'
     tg.qtde = 10
     tg.ovr_id = ovr.id
     tg.numerolote = 'CCNU1234567'
     session.add(tg)
     session.commit()
     # test xls file
     file_name = os.path.join(os.path.dirname(__file__), 'teste.xls')
     alert = importa_planilha_tg(session, tg, file_name)
     assert 'Campo procedencia(País Procedência, *****) não encontrado' in alert
     # test csv file
     file_name = os.path.join(os.path.dirname(__file__), 'teste_csv')
     alert = importa_planilha_tg(session, tg, file_name)
     assert 'Campo procedencia(País Procedência, *****) não encontrado' in alert
     # test ods file
     file_name = os.path.join(os.path.dirname(__file__), 'teste.ods')
     alert = importa_planilha_tg(session, tg, file_name)
     assert 'Campo procedencia(País Procedência, *****) não encontrado' in alert
     # test Exception file reading
     file_name_wrong = os.path.join(os.path.dirname(__file__), '123.abc')
     with self.assertRaises(Exception):
         alert = importa_planilha_tg(session, tg, file_name_wrong)
     # test broken file
     file_name = os.path.join(os.path.dirname(__file__),
                              'teste_sem_coluna_ncm.ods')
     alert = importa_planilha_tg(session, tg, file_name)
     assert alert.find("ncm") > 0
     # test broken file
     file_name = os.path.join(os.path.dirname(__file__),
                              'teste_sem_coluna_valor.ods')
     alert = importa_planilha_tg(session, tg, file_name)
     assert alert.find("valor") > 0