176 |
176 |
177 def test_expand_cubes(self): |
177 def test_expand_cubes(self): |
178 self.assertEqual(self.config.expand_cubes(('email', 'comment')), |
178 self.assertEqual(self.config.expand_cubes(('email', 'comment')), |
179 ['email', 'comment', 'file']) |
179 ['email', 'comment', 'file']) |
180 |
180 |
181 def test_appobjects_path(self): |
|
182 path = [unabsolutize(p) for p in self.config.appobjects_path()] |
|
183 self.assertEqual(path[0], 'entities') |
|
184 self.assertCountEqual(path[1:4], ['web/views', 'sobjects', 'hooks']) |
|
185 self.assertEqual(path[4], 'file/entities') |
|
186 self.assertCountEqual(path[5:7], |
|
187 ['file/views.py', 'file/hooks']) |
|
188 self.assertEqual(path[7], 'email/entities.py') |
|
189 self.assertCountEqual(path[8:10], |
|
190 ['email/views', 'email/hooks.py']) |
|
191 self.assertEqual(path[10:], ['test/data/entities.py', 'test/data/views.py']) |
|
192 |
181 |
193 def test_init_cubes_ignore_pyramid_cube(self): |
182 def test_init_cubes_ignore_pyramid_cube(self): |
194 warning_msg = 'cubicweb-pyramid got integrated into CubicWeb' |
183 warning_msg = 'cubicweb-pyramid got integrated into CubicWeb' |
195 with self.assertLogs('cubicweb.configuration', level='WARNING') as cm: |
184 with self.assertLogs('cubicweb.configuration', level='WARNING') as cm: |
196 self.config.init_cubes(['pyramid', 'card']) |
185 self.config.init_cubes(['pyramid', 'card']) |
461 ('foo', 'bar')) as config: |
450 ('foo', 'bar')) as config: |
462 self.assertEqual(pkgutil.find_loader('schema').get_filename(), |
451 self.assertEqual(pkgutil.find_loader('schema').get_filename(), |
463 join(libdir, 'schema.py')) |
452 join(libdir, 'schema.py')) |
464 self.assertEqual(config.schema_modnames(), expected) |
453 self.assertEqual(config.schema_modnames(), expected) |
465 |
454 |
466 |
455 @templibdir |
|
456 def test_appobjects_modnames(self, libdir): |
|
457 for filepath in ( |
|
458 join(libdir, 'entities.py'), |
|
459 join(libdir, 'cubicweb_foo', '__init__.py'), |
|
460 join(libdir, 'cubicweb_foo', 'entities', '__init__.py'), |
|
461 join(libdir, 'cubicweb_foo', 'entities', 'a.py'), |
|
462 join(libdir, 'cubicweb_foo', 'hooks.py'), |
|
463 join(libdir, 'cubes', '__init__.py'), |
|
464 join(libdir, 'cubes', 'bar', '__init__.py'), |
|
465 join(libdir, 'cubes', 'bar', 'hooks.py'), |
|
466 join(libdir, '_instance_dir', 'data1', 'entities.py'), |
|
467 join(libdir, '_instance_dir', 'data2', 'hooks.py'), |
|
468 ): |
|
469 create_filepath(filepath) |
|
470 instance_dir, cubes_dir = ( |
|
471 join(libdir, '_instance_dir'), join(libdir, 'cubes')) |
|
472 expected = [ |
|
473 'cubicweb.entities', |
|
474 'cubicweb.entities.adapters', |
|
475 'cubicweb.entities.authobjs', |
|
476 'cubicweb.entities.lib', |
|
477 'cubicweb.entities.schemaobjs', |
|
478 'cubicweb.entities.sources', |
|
479 'cubicweb.entities.wfobjs', |
|
480 'cubes.bar.hooks', |
|
481 'cubes.foo.entities', |
|
482 'cubes.foo.entities.a', |
|
483 'cubes.foo.hooks', |
|
484 ] |
|
485 # data1 has entities |
|
486 with temp_config('data1', instance_dir, cubes_dir, |
|
487 ('foo', 'bar')) as config: |
|
488 config.cube_appobject_path = set(['entities', 'hooks']) |
|
489 self.assertEqual(config.appobjects_modnames(), |
|
490 expected + ['entities']) |
|
491 # data2 has hooks |
|
492 with temp_config('data2', instance_dir, cubes_dir, |
|
493 ('foo', 'bar')) as config: |
|
494 config.cube_appobject_path = set(['entities', 'hooks']) |
|
495 self.assertEqual(config.appobjects_modnames(), |
|
496 expected + ['hooks']) |
467 |
497 |
468 |
498 |
469 if __name__ == '__main__': |
499 if __name__ == '__main__': |
470 unittest.main() |
500 unittest.main() |