Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add test for User.get_full_name()

fowczareke5ed88d5b2c4
diff --git a/tests/test_account.py b/tests/test_account.py
index 816036fb4c..cb7bc65904 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -213,6 +213,49 @@ def test_user_ajax_label_without_address(admin_user):
assert admin_user.get_ajax_label() == admin_user.email
[email protected]("email, first_name, last_name, full_name", [
+ ('[email protected]', 'John', 'Doe', 'John Doe'),
+ ('[email protected]', 'John', '', 'John'),
+ ('[email protected]', '', 'Doe', 'Doe'),
+])
+def test_get_full_name_user_with_names(email, first_name,
+ last_name, full_name, address):
+ user = User(email=email, first_name=first_name, last_name=last_name)
+ assert user.get_full_name() == full_name
+
+
[email protected]("email, first_name, last_name, full_name", [
+ ('[email protected]', 'John', 'Doe', 'John Doe'),
+ ('[email protected]', 'John', '', 'John'),
+ ('[email protected]', '', 'Doe', 'Doe'),
+])
+def test_get_full_name_user_with_address(email, first_name,
+ last_name, full_name, address):
+ copied_address = address.get_copy()
+ copied_address.first_name = first_name
+ copied_address.last_name = last_name
+ user = User(email=email, default_billing_address=copied_address)
+ assert user.get_full_name() == full_name
+
+
[email protected]("email, first_name, last_name, full_name", [
+ ('[email protected]', 'John', 'Doe', 'John Doe'),
+ ('[email protected]', 'John', '', 'John'),
+ ('[email protected]', '', 'Doe', 'Doe'),
+ ('[email protected]', '', '', 'Arnold Green'),
+])
+def test_get_full_name(email, first_name, last_name, full_name, address):
+ copied_address = address.get_copy()
+ copied_address.first_name = "Arnold"
+ copied_address.last_name = "Green"
+ user = User(
+ email=email, first_name=first_name, last_name=last_name,
+ default_billing_address=copied_address)
+ assert user.get_full_name() == full_name
+
+
def test_disabled_recaptcha():
"""
This test creates a new form that should not contain any recaptcha field.