@@ 105-114 (lines=10) @@ | ||
102 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
103 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
104 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
105 | ||
106 | def test_byApproval(self): |
|
107 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
|
108 | self.db.provenance.find.return_value = ['p1', 'p2'] |
|
109 | self.setupRepo() |
|
110 | a = 'AOk' |
|
111 | out = self.repo.byApproval(a) |
|
112 | self.db.provenance.find.assert_called_with({'approval':a}) |
|
113 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
114 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
115 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
116 | ||
117 | def test_updateApproval(self): |
|
@@ 94-103 (lines=10) @@ | ||
91 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
92 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
93 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
94 | ||
95 | def test_bySubject(self): |
|
96 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
|
97 | self.db.provenance.find.return_value = ['p1', 'p2'] |
|
98 | self.setupRepo() |
|
99 | s = 'Brambo' |
|
100 | out = self.repo.bySubject(s) |
|
101 | self.db.provenance.find.assert_called_with({'subject':s}) |
|
102 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
103 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
104 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
105 | ||
106 | def test_byApproval(self): |
|
@@ 177-185 (lines=9) @@ | ||
174 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
175 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
176 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
177 | ||
178 | def test_byParents(self): |
|
179 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
|
180 | self.db.provenance.find.return_value = ['p1', 'p2'] |
|
181 | self.setupRepo() |
|
182 | out = self.repo.byParents(['x1','x2']) |
|
183 | self.db.provenance.find.assert_called_with({'parents':{'$in':['x1','x2']}}) |
|
184 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
185 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
186 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
187 | ||
188 | def test_Converts_timedelta_to_float_when_serializing(self): |
|
@@ 167-175 (lines=9) @@ | ||
164 | self.fileFactory.fromProvenance.assert_called_with( |
|
165 | self.db.provenance.find_one()) |
|
166 | self.assertEqual(self.fileFactory.fromProvenance(), out) |
|
167 | ||
168 | def test_byLocations(self): |
|
169 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
|
170 | self.db.provenance.find.return_value = ['p1', 'p2'] |
|
171 | self.setupRepo() |
|
172 | out = self.repo.byLocations(['l1','l2']) |
|
173 | self.db.provenance.find.assert_called_with({'location':{'$in':['l1','l2']}}) |
|
174 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
175 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
176 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
177 | ||
178 | def test_byParents(self): |
|
@@ 84-92 (lines=9) @@ | ||
81 | self.repo.update(img) |
|
82 | self.db.provenance.update.assert_called_with( |
|
83 | {'location':img.location.toString()}, {'a':1, 'b':2}) |
|
84 | ||
85 | def test_all(self): |
|
86 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
|
87 | self.db.provenance.find.return_value = ['p1', 'p2'] |
|
88 | self.setupRepo() |
|
89 | out = self.repo.all() |
|
90 | self.db.provenance.find.assert_called_with() |
|
91 | self.fileFactory.fromProvenance.assert_any_call('p1') |
|
92 | self.fileFactory.fromProvenance.assert_any_call('p2') |
|
93 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
94 | ||
95 | def test_bySubject(self): |