def test_unsaved_contact(admin_user): payment_method = get_default_payment_method() _assign_component_for_service(payment_method, [PersonContact.get_default_group()]) person = PersonContact(name="Kalle") source = _get_source_for_contact(admin_user, payment_method) source.customer = person assert not person.pk and not source.customer.pk _test_service_availability(source, payment_method, False)
def _create_contact_from_address(self, billing_address, is_company): name = billing_address.get("name", None) if not name: self.add_error( ValidationError(_("Name is required for customer"), code="no_name")) return phone = billing_address.get("phone", "") email = billing_address.get("email", "") fields = {"name": name, "phone": phone, "email": email} if is_company: tax_number = billing_address.get("tax_number", None) if not tax_number: self.add_error( ValidationError(_("Tax number is not set for company."), code="no_tax_number")) return fields.update({"tax_number": tax_number}) customer = CompanyContact(**fields) else: customer = PersonContact(**fields) return customer
def test_person_name_init_by_first_and_last_name(): john = PersonContact(first_name="John", last_name="Smith") assert john.name == "John Smith" assert john.first_name == "John" assert john.last_name == "Smith"