@@ 140-152 (lines=13) @@ | ||
137 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p['l'] |
|
138 | from niprov.jsonfile import JsonFile |
|
139 | repo = JsonFile(self.dependencies) |
|
140 | img1 = self.imageWithProvenance({'parents':[],'l':'a'}) |
|
141 | img2 = self.imageWithProvenance({'parents':['x','a'],'l':'b'}) |
|
142 | img3 = self.imageWithProvenance({'parents':['b'],'l':'b'}) |
|
143 | img4 = self.imageWithProvenance({'parents':['c','y'],'l':'d'}) |
|
144 | img5 = self.imageWithProvenance({'parents':['d'],'l':'e'}) |
|
145 | repo.all = Mock() |
|
146 | repo.all.return_value = [img1, img2, img3, img4, img5] |
|
147 | out = repo.byParents(['x','y']) |
|
148 | self.assertEqual([img2, img4], out) |
|
149 | ||
150 | def test_Will_tell_PictureCache_to_persist_known_Snapshot(self): |
|
151 | from niprov.jsonfile import JsonFile |
|
152 | repo = JsonFile(self.dependencies) |
|
153 | img = self.imageWithProvenance({'location':'1','foo':'baz'}) |
|
154 | repo.add(img) |
|
155 | self.pictureCache.saveToDisk.assert_called_with(for_=img) |
|
@@ 204-215 (lines=12) @@ | ||
201 | self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p['l'] |
|
202 | from niprov.jsonfile import JsonFile |
|
203 | repo = JsonFile(self.dependencies) |
|
204 | i1 = self.imageWithProvenance({'color':'red'}) |
|
205 | i2 = self.imageWithProvenance({'location':'redis'}) |
|
206 | i3 = self.imageWithProvenance({'user':'reddit'}) |
|
207 | i4 = self.imageWithProvenance({'subject':'red bastard'}) |
|
208 | i5 = self.imageWithProvenance({'protocol':'reddish'}) |
|
209 | i6 = self.imageWithProvenance({'transformation':'zoomed red'}) |
|
210 | i7 = self.imageWithProvenance({'technique':'redshift'}) |
|
211 | i8 = self.imageWithProvenance({'modality':'red'}) |
|
212 | repo.all = Mock() |
|
213 | repo.all.return_value = [i1,i2,i3,i4,i5,i6,i7,i8] |
|
214 | out = repo.search('red') |
|
215 | self.assertNotIn(i1, out) |
|
216 | self.assertIn(i2, out) |
|
217 | self.assertIn(i3, out) |
|
218 | self.assertIn(i4, out) |