class TestUserLineService(unittest.TestCase): def setUp(self): self.old_service = Mock() self.user_dao = Mock() self.line_dao = Mock() self.service = UserLineService(self.old_service, self.user_dao, self.line_dao) def test_when_listing_associations_then_service_is_called(self): expected_user_lines = self.old_service.find_all_by_user_id.return_value result = self.service.list(sentinel.user_id) self.old_service.find_all_by_user_id.assert_called_once_with(sentinel.user_id) assert_that(result, equal_to(expected_user_lines)) def test_when_getting_association_then_service_is_called(self): expected_user_line = self.old_service.get_by_user_id_and_line_id.return_value result = self.service.get(sentinel.user_id, sentinel.line_id) self.old_service.get_by_user_id_and_line_id.assert_called_once_with(sentinel.user_id, sentinel.line_id) assert_that(result, equal_to(expected_user_line)) def test_when_associating_then_service_is_called(self): association = Mock() self.service.associate(association) self.old_service.associate.assert_called_once_with(association) def test_when_dissociating_then_service_is_called(self): association = Mock() self.service.dissociate(association) self.old_service.dissociate.assert_called_once_with(association)
def setUp(self): self.old_service = Mock() self.user_dao = Mock() self.line_dao = Mock() self.service = UserLineService(self.old_service, self.user_dao, self.line_dao)