|
@@ -219,7 +219,6 @@ class TestEmClassFields(ClassesTestCase):
|
219
|
219
|
# Creating a new EmClass should :
|
220
|
220
|
# - create a table named like the created EmClass
|
221
|
221
|
# - insert a new line in em_classes
|
222
|
|
-@unittest.skip("Not implemented yet")
|
223
|
222
|
class TestEmClassLinkType(ClassesTestCase):
|
224
|
223
|
|
225
|
224
|
# create a new EmClass, then test on it
|
|
@@ -228,31 +227,9 @@ class TestEmClassLinkType(ClassesTestCase):
|
228
|
227
|
ClassesTestCase.setUpClass()
|
229
|
228
|
test_entity = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testEntity', 'classtype': EmClassType.entity['name']})
|
230
|
229
|
test_entry = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testEntry', 'classtype': EmClassType.entry['name']})
|
231
|
|
- keywords = EM_TEST_OBJECT.create_component(EmType.__name__, {'name': 'keywords', 'class_id': test_entry.uid})
|
232
|
|
- test_entity.link_type(keywords)
|
233
|
230
|
|
234
|
|
- '''
|
|
231
|
+ def testLinkedTypes(self):
|
|
232
|
+ """ Test the EmClass.linked_types() method """
|
|
233
|
+ for field, linked_type in [ (f, EM_TEST_OBJECT.component(f.rel_to_type_id)) for f in EM_TEST_OBJECT.components(EmField) if 'rel_to_type_id' in f.__dict__]:
|
|
234
|
+ self.assertIn(linked_type, field.em_class.linked_types())
|
235
|
235
|
|
236
|
|
- # test if a table 'testEntity_keywords' was created
|
237
|
|
- # should be able to select on the created table
|
238
|
|
- def test_table_classes_types(self):
|
239
|
|
- """ Test if a table 'testEntity_keywords' was created """
|
240
|
|
- conn = sqlutils.get_engine().connect()
|
241
|
|
- a = sqlutils.meta(conn)
|
242
|
|
- try:
|
243
|
|
- newtable = sqla.Table('testEntity_keywords', sqlutils.meta(conn))
|
244
|
|
- req = sqla.sql.select([newtable])
|
245
|
|
- res = conn.execute(req)
|
246
|
|
- res = res.fetchall()
|
247
|
|
- conn.close()
|
248
|
|
- except:
|
249
|
|
- self.fail("unable to select table testEntity_keywords")
|
250
|
|
- self.assertEqual(res, [])
|
251
|
|
-
|
252
|
|
- # test if we can retrieve the linked type
|
253
|
|
- def test_linked_types(self):
|
254
|
|
- """ Test linked_types """
|
255
|
|
- testEntity = EmClass('testEntity')
|
256
|
|
- linked_types = testEntity.linked_types()
|
257
|
|
- self.assertEqual(linked_types[0].name, 'keywords')
|
258
|
|
- '''
|