def test_byLocation(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] out = repo.byLocation('2') self.assertEqual(img2, out)
def test_byLocation(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] out = repo.byLocation('2') self.assertEqual(img2, out)
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!')