|
@@ 140-152 (lines=13) @@
|
| 137 |
|
out = repo.byId('2') |
| 138 |
|
self.assertEqual(img2, out) |
| 139 |
|
|
| 140 |
|
def test_byLocations(self): |
| 141 |
|
self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p['a'] |
| 142 |
|
from niprov.jsonfile import JsonFile |
| 143 |
|
repo = JsonFile(self.dependencies) |
| 144 |
|
img1 = self.imageWithProvenance({'location':'i'}) |
| 145 |
|
img2 = self.imageWithProvenance({'location':'j'}) |
| 146 |
|
img3 = self.imageWithProvenance({'location':'m'}) |
| 147 |
|
img4 = self.imageWithProvenance({'location':'f'}) |
| 148 |
|
img5 = self.imageWithProvenance({'location':'x'}) |
| 149 |
|
repo.all = Mock() |
| 150 |
|
repo.all.return_value = [img1,img2,img3,img4,img5] |
| 151 |
|
out = repo.byLocations(['j','f','k']) |
| 152 |
|
self.assertEqual([img2, img4], out) |
| 153 |
|
|
| 154 |
|
def test_byParents(self): |
| 155 |
|
self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p['l'] |
|
@@ 204-215 (lines=12) @@
|
| 201 |
|
repo.all.return_value = [img1, img2] |
| 202 |
|
out = repo.search('red') |
| 203 |
|
self.assertEqual([img2], out) |
| 204 |
|
|
| 205 |
|
def test_Search_sorts_results_by_number_of_matches(self): |
| 206 |
|
self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p['l'] |
| 207 |
|
from niprov.jsonfile import JsonFile |
| 208 |
|
repo = JsonFile(self.dependencies) |
| 209 |
|
img1 = self.imageWithProvenance({'transformation':'red bluered'}) |
| 210 |
|
img2 = self.imageWithProvenance({'transformation':'red and green'}) |
| 211 |
|
img3 = self.imageWithProvenance({'transformation':'red pruple red red'}) |
| 212 |
|
img4 = self.imageWithProvenance({'transformation':'nuthin'}) |
| 213 |
|
repo.all = Mock() |
| 214 |
|
repo.all.return_value = [img1, img2, img3, img4] |
| 215 |
|
out = repo.search('red') |
| 216 |
|
self.assertEqual([img3, img1, img2], out) |
| 217 |
|
|
| 218 |
|
def test_Search_looks_through_multiple_fields(self): |