|
@@ 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_updateApproval(self): |
| 107 |
|
self.setupRepo() |
| 108 |
|
img = Mock() |
| 109 |
|
p = '/p/f1' |
| 110 |
|
newStatus = 'oh-oh' |
| 111 |
|
self.repo.updateApproval(p, newStatus) |
| 112 |
|
self.db.provenance.update.assert_called_with( |
| 113 |
|
{'location':p}, {'$set': {'approval': newStatus}}) |
| 114 |
|
|
| 115 |
|
def test_latest(self): |
| 116 |
|
self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
| 117 |
|
self.db.provenance.find.return_value = Mock() |
|
@@ 177-185 (lines=9) @@
|
| 174 |
|
self.fileFactory.fromProvenance.assert_any_call('p2') |
| 175 |
|
self.assertEqual(['img_p1', 'img_p2'], out) |
| 176 |
|
|
| 177 |
|
def test_Converts_timedelta_to_float_when_serializing(self): |
| 178 |
|
self.setupRepo() |
| 179 |
|
img = Mock() |
| 180 |
|
img.provenance = {'a':1, 'duration':timedelta(seconds=67.89)} |
| 181 |
|
self.repo.add(img) |
| 182 |
|
self.db.provenance.insert_one.assert_called_with( |
| 183 |
|
{'a':1, 'duration':67.89}) |
| 184 |
|
|
| 185 |
|
def test_Converts_duration_to_timedelta_when_deserializing(self): |
| 186 |
|
self.setupRepo() |
| 187 |
|
self.db.provenance.find_one.return_value = {'a':3, 'duration':89.01} |
| 188 |
|
out = self.repo.byLocation('/p/f1') |
|
@@ 167-175 (lines=9) @@
|
| 164 |
|
self.fileFactory.fromProvenance.assert_any_call('p2') |
| 165 |
|
self.assertEqual(['img_p1', 'img_p2'], out) |
| 166 |
|
|
| 167 |
|
def test_byParents(self): |
| 168 |
|
self.fileFactory.fromProvenance.side_effect = lambda p: 'img_'+p |
| 169 |
|
self.db.provenance.find.return_value = ['p1', 'p2'] |
| 170 |
|
self.setupRepo() |
| 171 |
|
out = self.repo.byParents(['x1','x2']) |
| 172 |
|
self.db.provenance.find.assert_called_with({'parents':{'$in':['x1','x2']}}) |
| 173 |
|
self.fileFactory.fromProvenance.assert_any_call('p1') |
| 174 |
|
self.fileFactory.fromProvenance.assert_any_call('p2') |
| 175 |
|
self.assertEqual(['img_p1', 'img_p2'], out) |
| 176 |
|
|
| 177 |
|
def test_Converts_timedelta_to_float_when_serializing(self): |
| 178 |
|
self.setupRepo() |
|
@@ 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_byApproval(self): |