
import pytest

from testfixtures.user import create_user_with_detail


@pytest.mark.parametrize(
    'first_names, last_name, expected',
    [
        (None,          None    , None                ),
        ('Giesbert Z.', None    , 'Giesbert Z.'       ),
        (None,          'Blümli', 'Blümli'            ),
        ('Giesbert Z.', 'Blümli', 'Giesbert Z. Blümli'),
    ],
)
def test_full_name(first_names, last_name, expected):
    user = create_user_with_detail(first_names=first_names, last_name=last_name)

    assert user.detail.full_name == expected


from datetime import datetime

import pytest

from byceps.services.user.models.user import User as DbUser
from byceps.services.user.models.detail import UserDetail as DbUserDetail


@pytest.mark.parametrize(
    'first_names, last_name, expected',
    [
        (None,          None    , None                ),
        ('Giesbert Z.', None    , 'Giesbert Z.'       ),
        (None,          'Blümli', 'Blümli'            ),
        ('Giesbert Z.', 'Blümli', 'Giesbert Z. Blümli'),
    ],
)
def test_full_name(first_names, last_name, expected):
    user = create_user(first_names, last_name)

    assert user.detail.full_name == expected


def create_user(first_names: str, last_name: str) -> DbUser:
    created_at = datetime.utcnow()
    screen_name = 'Anyone'
    email_address = 'anyone@example.test'

    user = DbUser(created_at, screen_name, email_address)

    detail = DbUserDetail(user=user)
    detail.first_names = first_names
    detail.last_name = last_name

    return user

Create fullname user object locally in test
Create fullname user object locally in test

+ 
+ from datetime import datetime
  
  import pytest
  
- from testfixtures.user import create_user_with_detail
+ from byceps.services.user.models.user import User as DbUser
+ from byceps.services.user.models.detail import UserDetail as DbUserDetail
  
  
  @pytest.mark.parametrize(
      'first_names, last_name, expected',
      [
          (None,          None    , None                ),
          ('Giesbert Z.', None    , 'Giesbert Z.'       ),
          (None,          'Blümli', 'Blümli'            ),
          ('Giesbert Z.', 'Blümli', 'Giesbert Z. Blümli'),
      ],
  )
  def test_full_name(first_names, last_name, expected):
-     user = create_user_with_detail(first_names=first_names, last_name=last_name)
+     user = create_user(first_names, last_name)
  
      assert user.detail.full_name == expected
  
+ 
+ def create_user(first_names: str, last_name: str) -> DbUser:
+     created_at = datetime.utcnow()
+     screen_name = 'Anyone'
+     email_address = 'anyone@example.test'
+ 
+     user = DbUser(created_at, screen_name, email_address)
+ 
+     detail = DbUserDetail(user=user)
+     detail.first_names = first_names
+     detail.last_name = last_name
+ 
+     return user
+ 
Create fullname user object locally in test
## Code Before:

import pytest

from testfixtures.user import create_user_with_detail


@pytest.mark.parametrize(
    'first_names, last_name, expected',
    [
        (None,          None    , None                ),
        ('Giesbert Z.', None    , 'Giesbert Z.'       ),
        (None,          'Blümli', 'Blümli'            ),
        ('Giesbert Z.', 'Blümli', 'Giesbert Z. Blümli'),
    ],
)
def test_full_name(first_names, last_name, expected):
    user = create_user_with_detail(first_names=first_names, last_name=last_name)

    assert user.detail.full_name == expected

## Instruction:
Create fullname user object locally in test
## Code After:

from datetime import datetime

import pytest

from byceps.services.user.models.user import User as DbUser
from byceps.services.user.models.detail import UserDetail as DbUserDetail


@pytest.mark.parametrize(
    'first_names, last_name, expected',
    [
        (None,          None    , None                ),
        ('Giesbert Z.', None    , 'Giesbert Z.'       ),
        (None,          'Blümli', 'Blümli'            ),
        ('Giesbert Z.', 'Blümli', 'Giesbert Z. Blümli'),
    ],
)
def test_full_name(first_names, last_name, expected):
    user = create_user(first_names, last_name)

    assert user.detail.full_name == expected


def create_user(first_names: str, last_name: str) -> DbUser:
    created_at = datetime.utcnow()
    screen_name = 'Anyone'
    email_address = 'anyone@example.test'

    user = DbUser(created_at, screen_name, email_address)

    detail = DbUserDetail(user=user)
    detail.first_names = first_names
    detail.last_name = last_name

    return user
