-
Notifications
You must be signed in to change notification settings - Fork 0
/
unittranslateutils2.py
60 lines (52 loc) · 2.92 KB
/
unittranslateutils2.py
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
# -*- coding: utf-8 -*-
from __future__ import print_function
#~ from __future__ import unicode_literals #python2: gives problems; this module contains unicode strings; in function ccode ascii strings are needed (for field).
import sys
import pickle
import unittest
import utilsunit
import bots.botsglobal as botsglobal
import bots.botslib as botslib
import bots.botsinit as botsinit
import bots.inmessage as inmessage
import bots.transform as transform
import bots.validate_email as validate_email
if sys.version_info[0] > 2:
basestring = unicode = str
'''plugin unittranslateutils.zip
in bots.ini: runacceptancetest = False
'''
class TestTranslate(unittest.TestCase):
def setUp(self):
pass
def testcodeconversion(self):
#codeconversion via tabel ccode OLD functionnames:
self.assertEqual('TESTOUT',transform.codetconversion('artikel','TESTIN'),'basis')
self.assertEqual('TESTOUT',transform.safecodetconversion('artikel','TESTIN'),'basis')
self.assertEqual('TESTINNOT',transform.safecodetconversion('artikel','TESTINNOT'),'basis')
self.assertRaises(botslib.CodeConversionError,transform.codetconversion,'artikel','TESTINNOT')
self.assertEqual('TESTIN',transform.rcodetconversion('artikel','TESTOUT'),'basis')
self.assertEqual('TESTIN',transform.safercodetconversion('artikel','TESTOUT'),'basis')
self.assertEqual('TESTINNOT',transform.safercodetconversion('artikel','TESTINNOT'),'basis')
self.assertRaises(botslib.CodeConversionError,transform.rcodetconversion,'artikel','TESTINNOT')
#attributes
self.assertEqual('TESTATTR1',transform.codetconversion('artikel','TESTIN','attr1'),'basis')
self.assertEqual('TESTATTR1',transform.safecodetconversion('artikel','TESTIN','attr1'),'basis')
#codeconversion via tabel ccode:
self.assertEqual('TESTOUT',transform.ccode('artikel','TESTIN'),'basis')
self.assertEqual('TESTOUT',transform.safe_ccode('artikel','TESTIN'),'basis')
self.assertEqual('TESTINNOT',transform.safe_ccode('artikel','TESTINNOT'),'basis')
self.assertRaises(botslib.CodeConversionError,transform.ccode,'artikel','TESTINNOT')
self.assertEqual('TESTIN',transform.reverse_ccode('artikel','TESTOUT'),'basis')
self.assertEqual('TESTIN',transform.safe_reverse_ccode('artikel','TESTOUT'),'basis')
self.assertEqual('TESTINNOT',transform.safe_reverse_ccode('artikel','TESTINNOT'),'basis')
self.assertRaises(botslib.CodeConversionError,transform.reverse_ccode,'artikel','TESTINNOT')
#attributes
self.assertEqual('TESTATTR1',transform.ccode('artikel','TESTIN','attr1'),'basis')
self.assertEqual('TESTATTR1',transform.safe_ccode('artikel','TESTIN','attr1'),'basis')
if __name__ == '__main__':
botsinit.generalinit('config')
botsglobal.logger = botsinit.initenginelogging('engine')
botsinit.connect()
unittest.main()
botsglobal.db.close()