def test_mandatory_exception(self): """Raise an error when the content is empty""" try: tra = ExportTra() tra._mandatory('', 10) pytest.fail('An empty content mandatory must raise and error') except MandatoryException: pass
def test_CAE_Notvalid(): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addCAE('4110001', 'Client X', nature='AUZ') pytest.fail('Not a valid value sent, must be raise and error') except NotValidValue: pass
def test_SAT_mandatory(self): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addSAT('PROJ1', 'Projet1') pytest.fail('Axe content is mandatory, missing value must be raise and error') except MandatoryException: pass
def test_SAT_export(self): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addSAT('PROJ1', 'Projet1', 'Axe1') content = tra._content['lines'][0] assert content[:3] == '***', 'Bad starting record!' assert len(content) == 251, 'SAT Line in 007 format must containt 251 characters' assert content[248:] == 'M ', 'Sens field must be set with M by default'
def test_ecriture_mandatory(): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addEcriture('VTE', type_piece='FC', type_compte='X', type_ecriture='N', sens='C') pytest.fail('Axe content is mandatory, missing value must be raise and error') except MandatoryException: pass
def test_ecriture_Notvalid(): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addEcriture('VTE', type_piece='FC') pytest.fail('Not a valid value sent, must be raise and error') except NotValidValue: pass
def test_header(self): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL', num_dossier='B105ZZ') content = tra.render() assert position(content, 1, 3) == '***', 'Bad starting record!' assert position(content, 4, 2) == 'S5', 'Bad identifiant!' assert position(content, 18, 8) == '01011900', 'Default date for "Date Bacule" not found!' assert position(content, 26, 8) == '01011900', 'Default date for "Date arrete periodique" not found!' assert position(content, 34, 3) == '007' assert position(content, 37, 5) == ' ' assert position(content, 42, 8) == time.strftime('%d%m%Y') assert position(content, 128, 6) == 'B105ZZ' assert position(content, 145, 3) == '001' assert len(content.replace('\r\n', '')) == 147, 'Record length not valid (%d)' % len(content)
def test_header(self): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL', num_dossier='B105ZZ') content = tra.render() assert position(content, 1, 3) == '***', 'Bad starting record!' assert position(content, 4, 2) == 'S5', 'Bad identifiant!' assert position( content, 18, 8) == '01011900', 'Default date for "Date Bacule" not found!' assert position( content, 26, 8 ) == '01011900', 'Default date for "Date arrete periodique" not found!' assert position(content, 34, 3) == '007' assert position(content, 37, 5) == ' ' assert position(content, 42, 8) == time.strftime('%d%m%Y') assert position(content, 128, 6) == 'B105ZZ' assert position(content, 145, 3) == '001' assert len(content.replace( '\r\n', '')) == 147, 'Record length not valid (%d)' % len(content)
def test_CAE_mandatory(): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addCAE('4110001', 'Client X', nature='AUC') tra.addEcriture('VTE', type_piece='FC', type_compte='X', type_ecriture='N', sens='C') pytest.fail( 'Axe content is mandatory, missing value must be raise and error') except MandatoryException: pass
def test_ecriture_normal(): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addEcriture('VTE', type_piece='FC', compte='41110001', type_compte='X', type_ecriture='N', sens='C', code_montant='C', date_creation='01012013', code_affaire='AAZZBB') assert len(tra._content['lines']) == 1 content = tra._content['lines'][0] assert position(content, 1, 3) != '***', 'Bad starting record!' assert position( content, 1, 3) == 'VTE' #, 'Starting record must be VTE in this exemple!' assert position(content, 130, 1) in ('C', 'D'), 'Sens must be filled with C or D' assert position(content, 131, 20) == '00000000000000000,00' assert position(content, 176, 20) == '00000000000000000,00' assert position(content, 196, 20) == '00000000000000000,00' assert position(content, 258, 8) == '01011900' assert position(content, 266, 8) == '01012013' assert position(content, 277, 17) == 'AAZZBB'.ljust(17) assert len( content ) == 293, 'Ecriture Line in 007 format must containt 222 characters (found %d)' % len( content)
def test_ecriture_normal(): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addEcriture('VTE', type_piece='FC', compte='41110001', type_compte='X', type_ecriture='N', sens='C', code_montant='C', date_creation='01012013', code_affaire='AAZZBB') assert len(tra._content['lines']) == 1 content = tra._content['lines'][0] assert position(content, 1, 3) != '***', 'Bad starting record!' assert position(content, 1, 3) == 'VTE' #, 'Starting record must be VTE in this exemple!' assert position(content, 130, 1) in ('C', 'D'), 'Sens must be filled with C or D' assert position(content, 131, 20) == '00000000000000000,00' assert position(content, 176, 20) == '00000000000000000,00' assert position(content, 196, 20) == '00000000000000000,00' assert position(content, 258, 8) == '01011900' assert position(content, 266, 8) == '01012013' assert position(content, 277, 17) == 'AAZZBB'.ljust(17) assert len(content) == 293, 'Ecriture Line in 007 format must containt 222 characters (found %d)' % len(content)
def test_SAT_mandatory(self): try: tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addSAT('PROJ1', 'Projet1') pytest.fail( 'Axe content is mandatory, missing value must be raise and error' ) except MandatoryException: pass
def test_SAT_export(self): tra = ExportTra() tra.setHeader('S5', 'CLI', 'JRL') tra.addSAT('PROJ1', 'Projet1', 'Axe1') content = tra._content['lines'][0] assert content[:3] == '***', 'Bad starting record!' assert len( content ) == 251, 'SAT Line in 007 format must containt 251 characters' assert content[ 248:] == 'M ', 'Sens field must be set with M by default'
def test_debug(self): tra = ExportTra() tra.setDebug(200) assert tra._debug_header == 200, 'Bad debug header length'
def test_format_1(self): tra = ExportTra() content = tra._format('OK', 10) assert len(content) == 10 assert content[:2] == 'OK', "Content doesn't start with OK!"
def test_format_2(self): tra = ExportTra() content = tra._format('OK', 10, True) assert len(content) == 10 assert content[8:] == 'OK', "Content doesn't end with OK!"
def test_format_4(self): tra = ExportTra() content = tra._format('OK', 10, True, caract='=') assert len(content) == 10 assert content == '========OK'
def test_mandatory_standard(self): tra = ExportTra() content = tra._mandatory('OK', 10) assert len(content) == 10
def test_header(self): tra = ExportTra() tra.changeFormat('009') tra.setHeader('S5', 'CLI', 'JRL', num_dossier='B105ZZ') content = tra.render() assert position(content, 34, 3) == '009'