Skip to content
Newer
Older
100644 63 lines (49 sloc) 1.73 KB
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
1 from disco.job import JobChain
2 from disco.test import TestCase, TestJob
a7d2296 @jflatow added new multijobtestfixture and associated tests (test_oob identifi…
jflatow authored Nov 30, 2009
3
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
4 from disco.worker.classic import func
a7d2296 @jflatow added new multijobtestfixture and associated tests (test_oob identifi…
jflatow authored Nov 30, 2009
5
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
6 class ChainJobA(TestJob):
7 partitions = 4
8 params = {'suffix': '0'}
9 sort = False
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
10
11 @staticmethod
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
12 def map(e, params):
5d9150f @jflatow changed the default reader from map_line_reader to None (which return…
jflatow authored Aug 5, 2010
13 yield e.strip() + params['suffix'], 0
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
14
15 @staticmethod
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
16 def reduce(iter, params):
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
17 for k, v in iter:
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
18 yield k + '-', v
19
20 class ChainJobB(TestJob):
21 map_reader = staticmethod(func.chain_reader)
22 partitions = 4
23 params = {'suffix': '1'}
24 sort = False
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
25
26 @staticmethod
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
27 def map((k, v), params):
28 yield k + params['suffix'], v + 1
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
29
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
30 reduce = staticmethod(ChainJobA.reduce)
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
31
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
32 class ChainTestCase(TestCase):
33 animals = ['horse', 'sheep', 'whale', 'tiger']
34
35 def serve(self, path):
36 return '\n'.join(self.animals)
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
37
38 def runTest(self):
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
39 a, b = ChainJobA(), ChainJobB()
40 self.job = JobChain({a: self.test_server.urls([''] * 100),
41 b: a}).wait()
42 for key, value in self.results(b):
11269cb Change indentation from 8 to 4 spaces (all files modified!)
Ville Tuulos authored Feb 11, 2010
43 self.assert_(key[:5] in self.animals)
44 self.assertEquals(key[5:], '0-1-')
be57041 fixed tests, expect str->int with new data format
Ville Tuulos authored Apr 20, 2010
45 self.assertEquals(value, 1)
a7d2296 @jflatow added new multijobtestfixture and associated tests (test_oob identifi…
jflatow authored Nov 30, 2009
46
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
47 class DavinChainJobA(TestJob):
9b8a4a0 @jflatow update the new worker interface and refactor classic worker to suppor…
jflatow authored Mar 16, 2011
48 @staticmethod
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
49 def map(e, params):
79606ca @jflatow added test to replicate davins no map multi reduce bug
jflatow authored Feb 11, 2010
50 yield e, ''
51
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
52 class DavinChainJobC(TestJob):
53 reduce = staticmethod(func.nop_reduce)
79606ca @jflatow added test to replicate davins no map multi reduce bug
jflatow authored Feb 11, 2010
54
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
55 class DavinChainTestCase(TestCase):
79606ca @jflatow added test to replicate davins no map multi reduce bug
jflatow authored Feb 11, 2010
56 def runTest(self):
34ec37c @jflatow test magic removal: get rid of pre-Job/JobChain fixtures from disco.t…
jflatow authored Apr 3, 2011
57 a, b, c = DavinChainJobA(), DavinChainJobA(), DavinChainJobC()
58 self.job = JobChain({a: ['raw://0', 'raw://1', 'raw://2'],
59 b: ['raw://3', 'raw://4', 'raw://5'],
60 c: [a, b]}).wait()
61 self.assertAllEqual(sorted(self.results(c)),
62 ((str(x), '') for x in xrange(6)))
Something went wrong with that request. Please try again.