Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

1
0

find_section.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import unittest
  2. from odml import Section
  3. class TestFindSections(unittest.TestCase):
  4. def setUp(self):
  5. self.root_section = Section("Type test", "test")
  6. self.root_section.append(Section("sub_1", "sub_1"))
  7. self.root_section.append(Section("sub_2", "sub_2"))
  8. self.root_section.append(Section("sub_2_b", "sub_2"))
  9. self.root_section.append(Section("sub_3", "sub_2/sub_3"))
  10. def test_find_by_name(self):
  11. ret = self.root_section.find("sub_1")
  12. self.assertTrue(ret.name == "sub_1")
  13. ret = self.root_section.find("unknown_type")
  14. self.assertIsNone(ret)
  15. def test_find_by_type(self):
  16. ret = self.root_section.find(type="sub_1")
  17. self.assertTrue(ret is not None and ret.type == "sub_1")
  18. ret = self.root_section.find(type="sub_2", findAll=True)
  19. self.assertTrue(len(ret) == 2)
  20. ret = self.root_section.find(key=None, type="sub_2", findAll=True, include_subtype=True)
  21. self.assertTrue(len(ret) == 3)
  22. def test_find_by_name_and_type(self):
  23. ret = self.root_section.find(key="sub_1", type="sub_1")
  24. self.assertTrue(ret.name == "sub_1")
  25. ret = self.root_section.find(key="sub_1", type="sub_2")
  26. self.assertIsNone(ret)
  27. if __name__ == '__main__':
  28. suite = unittest.TestLoader().loadTestsFromTestCase(TestFindSections)
  29. unittest.TextTestRunner(verbosity=2).run(suite)