Debian Codegraph @

testing/mozharness/test/test_base_parallel.py

raw
1 import unittest
2
3 import mozunit
4 from mozharness.base.parallel import ChunkingMixin
5
6
7 class TestChunkingMixin(unittest.TestCase):
8 def setUp(self):
9 self.c = ChunkingMixin()
10
11 def test_one_chunk(self):
12 self.assertEqual(self.c.query_chunked_list([1, 3, 2], 1, 1), [1, 3, 2])
13
14 def test_sorted(self):
15 self.assertEqual(
16 self.c.query_chunked_list([1, 3, 2], 1, 1, sort=True), [1, 2, 3]
17 )
18
19 def test_first_chunk(self):
20 self.assertEqual(self.c.query_chunked_list([4, 5, 4, 3], 1, 2), [4, 5])
21
22 def test_last_chunk(self):
23 self.assertEqual(self.c.query_chunked_list([1, 4, 5, 7, 5, 6], 3, 3), [5, 6])
24
25 def test_not_evenly_divisble(self):
26 thing = [1, 3, 6, 4, 3, 2, 6]
27 self.assertEqual(self.c.query_chunked_list(thing, 1, 3), [1, 3, 6])
28 self.assertEqual(self.c.query_chunked_list(thing, 2, 3), [4, 3])
29 self.assertEqual(self.c.query_chunked_list(thing, 3, 3), [2, 6])
30
31
32 if __name__ == "__main__":
33 mozunit.main()