def create_account(customer_id, account_repository, customer_client): if not customer_client.has_customer_with_id(customer_id): raise CustomerNotFound() account = Account(customer_id=customer_id, account_status='active') account_repository.store(account) return account.formatted_account_number
def test_post_accounts_when_customer_does_not_exist(create_account, web_client, account_repository, customer_client): create_account.side_effect = CustomerNotFound() response = web_client.post('/accounts/', json={'customerId': '12345'}) assert response.status_code == 400 assert response.is_json assert response.get_json() == {'message': 'Customer not found'}
def create_account(account, account_repository, customer_client): if not customer_client.has_customer_with_id(account.customer_id): raise CustomerNotFound() account_repository.store(account)