def test_it_finds_the_service(self, celery, user): worker.rename_user(user.id, 'panda') celery.request.find_service.assert_called_once_with(name='rename_user')
def test_it_renames_the_user(self, celery, user): service = celery.request.find_service.return_value worker.rename_user(user.id, 'panda') service.rename.assert_called_once_with(user, 'panda')
def test_it_raises_when_user_cannot_be_found(self, celery): with pytest.raises(ValueError) as err: worker.rename_user(4, 'panda') assert err.value.message == 'Could not find user with id 4'