|
@@ -1,30 +1,15 @@
|
1
|
1
|
import os
|
2
|
2
|
import logging
|
3
|
|
-import datetime
|
4
|
|
-import shutil
|
5
|
|
-
|
6
|
|
-from django.conf import settings
|
7
|
3
|
|
8
|
4
|
from unittest import TestCase
|
9
|
|
-import unittest
|
10
|
5
|
|
11
|
|
-from EditorialModel.components import EmComponent, EmComponentNotExistError
|
12
|
6
|
from EditorialModel.fieldgroups import EmFieldGroup
|
13
|
7
|
from EditorialModel.classes import EmClass
|
14
|
8
|
from EditorialModel.types import EmType
|
15
|
9
|
from EditorialModel.fields import EmField
|
16
|
|
-from EditorialModel.classtypes import EmClassType
|
17
|
|
-from EditorialModel.fieldtypes import *
|
18
|
|
-
|
19
|
|
-#from EditorialModel.test.utils import *
|
20
|
10
|
from Lodel.utils.mlstring import MlString
|
21
|
|
-from Database import sqlutils
|
22
|
|
-
|
23
|
|
-import sqlalchemy as sqla
|
24
|
|
-
|
25
|
11
|
from EditorialModel.model import Model
|
26
|
12
|
from EditorialModel.backend.json_backend import EmBackendJson
|
27
|
|
-#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Lodel.settings")
|
28
|
13
|
|
29
|
14
|
#=###########=#
|
30
|
15
|
# TESTS SETUP #
|
|
@@ -42,31 +27,14 @@ def setUpModule():
|
42
|
27
|
|
43
|
28
|
logging.basicConfig(level=logging.CRITICAL)
|
44
|
29
|
|
45
|
|
- #initTestDb(TEST_FIELDGROUP_DBNAME)
|
46
|
|
- #setDbConf(TEST_FIELDGROUP_DBNAME)
|
47
|
|
-
|
48
|
|
- #Classes creation
|
49
|
|
- #EmClass.create("entity1", EmClassType.entity)
|
50
|
|
- #EmClass.create("entity2", EmClassType.entity)
|
51
|
|
- #EmClass.create("entry1", EmClassType.entry)
|
52
|
|
- #EmClass.create("entry2", EmClassType.entry)
|
53
|
|
- #EmClass.create("person1", EmClassType.person)
|
54
|
|
- #EmClass.create("person2", EmClassType.person)
|
55
|
|
-
|
56
|
|
- #saveDbState(TEST_FIELDGROUP_DBNAME)
|
57
|
|
-
|
58
|
|
- #shutil.copyfile(TEST_FIELDGROUP_DBNAME, globals()['fieldgroup_test_dbfilename']+'_bck')
|
59
|
|
-
|
60
|
30
|
|
61
|
31
|
def tearDownModule():
|
62
|
|
- #cleanDb(TEST_FIELDGROUP_DBNAME)
|
63
|
32
|
pass
|
64
|
33
|
|
65
|
34
|
|
66
|
35
|
class FieldGroupTestCase(TestCase):
|
67
|
36
|
|
68
|
37
|
def setUp(self):
|
69
|
|
- #restoreDbState(TEST_FIELDGROUP_DBNAME)
|
70
|
38
|
pass
|
71
|
39
|
|
72
|
40
|
|
|
@@ -74,29 +42,6 @@ class FieldGroupTestCase(TestCase):
|
74
|
42
|
# EmFielgroup.__init__ #
|
75
|
43
|
#======================#
|
76
|
44
|
class TestInit(FieldGroupTestCase):
|
77
|
|
- '''
|
78
|
|
- def setUp(self):
|
79
|
|
- super(TestInit, self).setUp()
|
80
|
|
- dbe = sqlutils.get_engine()
|
81
|
|
- conn = sqlutils.get_engine().connect()
|
82
|
|
-
|
83
|
|
- ent1 = EmClass('entity1')
|
84
|
|
- idx1 = EmClass('entry1')
|
85
|
|
-
|
86
|
|
-
|
87
|
|
- self.creadate = datetime.datetime.utcnow()
|
88
|
|
- #Test fieldgroup
|
89
|
|
- self.tfg = [
|
90
|
|
- { 'uid': EmFieldGroup.new_uid(dbe), 'name': 'fg1', 'string': '{"fr":"Super Fieldgroup"}', 'help': '{"en":"help"}', 'rank': 0 , 'class_id': ent1.uid, 'date_create' : self.creadate, 'date_update': self.creadate},
|
91
|
|
- { 'uid': EmFieldGroup.new_uid(dbe), 'name': 'fg2', 'string': '{"fr":"Super Fieldgroup"}', 'help': '{"en":"help"}', 'rank': 1 , 'class_id': ent1.uid, 'date_create': self.creadate, 'date_update': self.creadate},
|
92
|
|
- { 'uid': EmFieldGroup.new_uid(dbe), 'name': 'fg3', 'string': '{"fr":"Super Fieldgroup"}', 'help': '{"en":"help"}', 'rank': 2 , 'class_id': idx1.uid, 'date_create': self.creadate, 'date_update': self.creadate},
|
93
|
|
- ]
|
94
|
|
-
|
95
|
|
- req = sqla.Table('em_fieldgroup', sqlutils.meta(sqlutils.get_engine())).insert(self.tfg)
|
96
|
|
- conn.execute(req)
|
97
|
|
- conn.close()
|
98
|
|
- pass
|
99
|
|
- '''
|
100
|
45
|
|
101
|
46
|
def setUp(self):
|
102
|
47
|
super(TestInit, self).setUp()
|