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_leobjectidentifier.py 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  3. #
  4. # Copyright (C) 2015-2017 Cléo UMS-3287
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published
  8. # by the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import unittest
  20. import inspect
  21. from unittest import mock
  22. from lodel.leapi.datahandlers.datas import LeobjectSubclassIdentifier as Testee
  23. class LeresultectSubclassIdentifierTestCase(unittest.TestCase):
  24. def test_base_type_is_varchar(self):
  25. self.assertEqual(Testee.base_type, 'varchar')
  26. def test_help_property_str_is_set(self):
  27. self.assertEqual(type(Testee.help), str)
  28. def test_throws_error_if_set_as_external(self):
  29. self.assertRaises(RuntimeError, Testee, internal=False)
  30. def test_set_as_internal_by_default(self):
  31. self.assertTrue(Testee().internal)
  32. def test_passing_class_returns_class_name(self):
  33. result = Testee.construct_data(None, object, None, None, None)
  34. self.assertEqual(result, object.__name__)
  35. def test_passing_instance_returns_class_name(self):
  36. result = Testee.construct_data(None, object(), None, None, None)
  37. self.assertTrue(result, object.__name__)
  38. def test_passing_instance_and_class_same_result(self):
  39. objResult = Testee.construct_data(None, Testee(), None, None, None)
  40. clsResult = Testee.construct_data(None, Testee, None, None, None)
  41. self.assertEqual(objResult, clsResult)