def test_finds_by_token_returns_the_expected_customer(self, database): customer = Customer.create( first_name = self.first_name, last_name = self.last_name, company = self.company, email = self.email, phone = self.phone, fax = self.fax, website = self.website ) assert Customer.query.count() == 1 assert Customer.find_by_token('somenonexistingtoken') is None assert Customer.find_by_token(customer.token) == customer
def create_customer(self): customer = Customer.find_by_token(self.customer_token) if customer is None: customer = Customer.find_by_email(self.details['email']) if customer is None: processor_information = self._register_customer_with_processor( self.processor_name, self.details) customer = Customer.create(**self.details) PaymentProcessorCustomerInformationCreate.call( self.processor_name, customer, processor_information) return customer
def _find_customer(self, token: str): self.customer = Customer.find_by_token(token) if self.customer is None: raise InvalidCustomer