def test_Update(self): from niprov.jsonfile import JsonFile repo = JsonFile(self.dependencies) img1 = self.imageWithProvenance({'location': '1', 'path': 'a'}) img2 = self.imageWithProvenance({'location': '2', 'path': 'b'}) repo.all = Mock() repo.all.return_value = [img1, img2] image = self.imageWithProvenance({'location': '2', 'foo': 'bar'}) repo.update(image) self.serializer.serializeList.assert_called_with([img1, image]) self.filesys.write.assert_called_with(repo.datafile, self.serializer.serializeList())
def test_Update(self): from niprov.jsonfile import JsonFile repo = JsonFile(self.dependencies) img1 = self.imageWithProvenance({'location':'1','path':'a'}) img2 = self.imageWithProvenance({'location':'2','path':'b'}) repo.all = Mock() repo.all.return_value = [img1, img2] image = self.imageWithProvenance({'location': '2','foo':'bar'}) repo.update(image) self.serializer.serializeList.assert_called_with( [img1,image]) self.filesys.write.assert_called_with(repo.datafile, self.serializer.serializeList())
def test_updateApproval(self): from niprov.jsonfile import JsonFile repo = JsonFile(self.dependencies) img = Mock() img.provenance = {'fiz':'baf','approval':'notsure'} def assertion(img): self.assertEqual({'fiz':'baf','approval':'excellent!'}, img.provenance) repo.byLocation = Mock() repo.byLocation.return_value = img repo.update = Mock() repo.update.side_effect = assertion repo.updateApproval('/p/f1','excellent!')
def test_updateApproval(self): from niprov.jsonfile import JsonFile repo = JsonFile(self.dependencies) img = Mock() img.provenance = {'fiz': 'baf', 'approval': 'notsure'} def assertion(img): self.assertEqual({ 'fiz': 'baf', 'approval': 'excellent!' }, img.provenance) repo.byLocation = Mock() repo.byLocation.return_value = img repo.update = Mock() repo.update.side_effect = assertion repo.updateApproval('/p/f1', 'excellent!')