def test_map_groups(mock_time): # TODO: refactor to test batch_size on_finish = Mock() def callback(item): def is_finished(): return 'result' return is_finished groups = {'g1': [1, 2, 3], 'g2': [4, 5, 6, 7, 8, 9, 10]} result = utils.map_groups(callback, groups, 3, on_finish, 1.0) expected_result = [call(_, 'result') for _ in xrange(10)] assert testutils.check_items_equal(result, expected_result) assert testutils.check_items_equal(on_finish.mock_calls, expected_result) mock_time.sleep.assert_called_with(1.0)
def test_check_items_equal(): assert testutils.check_items_equal([1, 2], [2, 1]) assert not testutils.check_items_equal([1, 2], [1, 2, 3])
def test_monitored_paths(self): check_items_equal(self.plugin.monitored_paths, ['/a/b/e/f', '/a/b/g/h']) plugin = plugins.Plugin({}, mock_attr(path='/a/b')) eq_(plugin.monitored_paths, ['/a/b'])