No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_leclass.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """
  2. Test for LeClass
  3. """
  4. import unittest
  5. from unittest import TestCase
  6. import EditorialModel
  7. import leapi
  8. import DataSource.dummy
  9. import leapi.test.utils
  10. class LeClassTestCase(TestCase):
  11. @classmethod
  12. def setUpClass(cls):
  13. """ Write the generated code in a temporary directory and import it """
  14. cls.tmpdir = leapi.test.utils.tmp_load_factory_code()
  15. @classmethod
  16. def tearDownClass(cls):
  17. """ Remove the temporary directory created at class setup """
  18. leapi.test.utils.cleanup(cls.tmpdir)
  19. def test_fieldlist(self):
  20. """ Testing fieldlist method """
  21. from dyncode import Publication, Personnes, Textes, LeObject
  22. for leclass in [ Publication, Personnes, Textes ]:
  23. for fieldname in leclass.fieldlist(complete = False):
  24. ftype = leclass.fieldtypes()[fieldname]
  25. self.assertNotIn(
  26. fieldname,
  27. LeObject.fieldlist()
  28. )
  29. for obj_fname in LeObject.fieldlist():
  30. self.assertIn(
  31. obj_fname,
  32. leclass.fieldlist(complete = True)
  33. )
  34. def test_fieldtypes(self):
  35. """ Testing the fieldtypes() method """
  36. from dyncode import Publication, Personnes, Textes, LeObject
  37. for leclass in [ Publication, Personnes, Textes ]:
  38. for complete in [ True, False ]:
  39. self.assertEqual(
  40. sorted(list(leclass.fieldtypes(complete).keys())),
  41. sorted(leclass.fieldlist(complete)),
  42. )