test_utils.py 760B

1234567891011121314151617181920212223242526272829
  1. # coding: utf-8
  2. from synergine2.utils import ChunkManager
  3. from tests import BaseTest
  4. class TestUtils(BaseTest):
  5. def test_chunk_manager_round(self):
  6. chunk_manager = ChunkManager(4)
  7. data = list(range(100))
  8. chunks = chunk_manager.make_chunks(data)
  9. assert len(chunks) == 4
  10. for chunk in chunks:
  11. assert len(chunk) == 25
  12. def test_chunk_manager_not_round(self):
  13. chunk_manager = ChunkManager(4)
  14. data = list(range(101))
  15. chunks = chunk_manager.make_chunks(data)
  16. assert len(chunks) == 4
  17. for chunk_number, chunk in enumerate(chunks):
  18. if chunk_number == 3:
  19. assert len(chunk) == 26
  20. else:
  21. assert len(chunk) == 25