class TestTransferValidator(unittest.TestCase): def setUp(self): self.dao = Mock() self.validator = TransferValidator(self.dao) def test_given_transfer_does_not_exist_when_validating_then_raises_error(self): self.dao.find_all_transfer_extensions.return_value = [] destination = TransferDestination(transfer='blind') assert_that(calling(self.validator.validate).with_args(destination), raises(InputError)) def test_given_transfer_exists_when_validating_then_validation_passes(self): transfer_extensions = [TransferExtension(id=sentinel.extension_id, exten='*1', transfer='blind'), TransferExtension(id=sentinel.extension_id, exten='*2', transfer='attended')] self.dao.find_all_transfer_extensions.return_value = transfer_extensions destination = TransferDestination(transfer='blind') self.validator.validate(destination) self.dao.find_all_transfer_extensions.assert_called_once_with()
def setUp(self): self.dao = Mock() self.validator = TransferValidator(self.dao)