@@ 177-185 (lines=9) @@ | ||
174 | def test_Converts_duration_to_timedelta_when_deserializing(self): |
|
175 | self.setupRepo() |
|
176 | self.db.provenance.find_one.return_value = {'a':3, 'duration':89.01} |
|
177 | out = self.repo.byLocation('/p/f1') |
|
178 | self.fileFactory.fromProvenance.assert_called_with( |
|
179 | {'a':3, 'duration':timedelta(seconds=89.01)}) |
|
180 | ||
181 | def test_Obtains_optional_snapshot_data_from_cache_when_serializing(self): |
|
182 | self.pictureCache.getBytes.return_value = sentinel.snapbytes |
|
183 | with patch('niprov.mongo.bson') as bson: |
|
184 | bson.Binary.return_value = sentinel.snapbson |
|
185 | self.setupRepo() |
|
186 | img = Mock() |
|
187 | img.provenance = {'a':1} |
|
188 | self.repo.add(img) |
|
@@ 167-175 (lines=9) @@ | ||
164 | self.assertEqual(['img_p1', 'img_p2'], out) |
|
165 | ||
166 | def test_Converts_timedelta_to_float_when_serializing(self): |
|
167 | self.setupRepo() |
|
168 | img = Mock() |
|
169 | img.provenance = {'a':1, 'duration':timedelta(seconds=67.89)} |
|
170 | self.repo.add(img) |
|
171 | self.db.provenance.insert_one.assert_called_with( |
|
172 | {'a':1, 'duration':67.89}) |
|
173 | ||
174 | def test_Converts_duration_to_timedelta_when_deserializing(self): |
|
175 | self.setupRepo() |
|
176 | self.db.provenance.find_one.return_value = {'a':3, 'duration':89.01} |
|
177 | out = self.repo.byLocation('/p/f1') |
|
178 | self.fileFactory.fromProvenance.assert_called_with( |
|
@@ 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_updateApproval(self): |