Show More
@@ -627,4 +627,52 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
627 | self.assertTrue(all(isinstance(d, dict) for d in ar.data)) |
|
627 | self.assertTrue(all(isinstance(d, dict) for d in ar.data)) | |
628 | ar.get(5) |
|
628 | ar.get(5) | |
629 | self.assertEqual(ar.data, [dict(i=4)] * len(ar)) |
|
629 | self.assertEqual(ar.data, [dict(i=4)] * len(ar)) | |
|
630 | ||||
|
631 | def test_can_list_arg(self): | |||
|
632 | """args in lists are canned""" | |||
|
633 | view = self.client[-1] | |||
|
634 | view['a'] = 128 | |||
|
635 | rA = pmod.Reference('a') | |||
|
636 | ar = view.apply_async(lambda x: x, [rA]) | |||
|
637 | r = ar.get(5) | |||
|
638 | self.assertEqual(r, [128]) | |||
|
639 | ||||
|
640 | def test_can_dict_arg(self): | |||
|
641 | """args in dicts are canned""" | |||
|
642 | view = self.client[-1] | |||
|
643 | view['a'] = 128 | |||
|
644 | rA = pmod.Reference('a') | |||
|
645 | ar = view.apply_async(lambda x: x, dict(foo=rA)) | |||
|
646 | r = ar.get(5) | |||
|
647 | self.assertEqual(r, dict(foo=128)) | |||
|
648 | ||||
|
649 | def test_can_list_kwarg(self): | |||
|
650 | """kwargs in lists are canned""" | |||
|
651 | view = self.client[-1] | |||
|
652 | view['a'] = 128 | |||
|
653 | rA = pmod.Reference('a') | |||
|
654 | ar = view.apply_async(lambda x=5: x, x=[rA]) | |||
|
655 | r = ar.get(5) | |||
|
656 | self.assertEqual(r, [128]) | |||
|
657 | ||||
|
658 | def test_can_dict_kwarg(self): | |||
|
659 | """kwargs in dicts are canned""" | |||
|
660 | view = self.client[-1] | |||
|
661 | view['a'] = 128 | |||
|
662 | rA = pmod.Reference('a') | |||
|
663 | ar = view.apply_async(lambda x=5: x, dict(foo=rA)) | |||
|
664 | r = ar.get(5) | |||
|
665 | self.assertEqual(r, dict(foo=128)) | |||
|
666 | ||||
|
667 | def test_map_ref(self): | |||
|
668 | """view.map works with references""" | |||
|
669 | view = self.client[:] | |||
|
670 | ranks = sorted(self.client.ids) | |||
|
671 | view.scatter('rank', ranks, flatten=True) | |||
|
672 | rrank = pmod.Reference('rank') | |||
|
673 | ||||
|
674 | amr = view.map_async(lambda x: x*2, [rrank] * len(view)) | |||
|
675 | drank = amr.get(5) | |||
|
676 | self.assertEqual(drank, [ r*2 for r in ranks ]) | |||
|
677 | ||||
630 |
|
678 |
General Comments 0
You need to be logged in to leave comments.
Login now