# Path: standup/status/tests/factories.py
# class StandupUserFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.StandupUser'
# 
#     user = factory.SubFactory(UserFactory)
#     slug = factory.LazyAttribute(lambda obj: slugify(obj.user.username))
#     irc_nick = factory.Faker('user_name')
#     # FIXME: teams
# 
# class StatusFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.Status'
# 
#     created = fuzzy.FuzzyDateTime(
#         start_dt=datetime(2011, 9, 6, 0, 0, 0, tzinfo=pytz.utc)
#     )
#     user = factory.SubFactory(StandupUserFactory)
#     project = factory.SubFactory(ProjectFactory)
#     content = factory.Faker('sentence')
# 
# class TeamFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.Team'
#     name = factory.Faker('name')
#     slug = factory.LazyAttribute(lambda obj: slugify(obj.name))
# 
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'auth.User'
# 
#     username = factory.Faker('user_name')
#     first_name = factory.Faker('first_name')
#     last_name = factory.Faker('last_name')
#     email = factory.Faker('email')
#     password = factory.PostGenerationMethodCall('set_password', 'nopassword')
# 
#     is_active = True
#     is_staff = False
#     is_superuser = False


from django.core.management import call_command
from django.utils.six import StringIO
from standup.status.tests.factories import (
    StandupUserFactory,
    StatusFactory,
    TeamFactory,
    UserFactory,
)
import pytest
    stdout = StringIO()
    call_command('finduser', 'willkg', stdout=stdout)
    output = stdout.getvalue().splitlines()
    assert len(output) == 4
    for i, starter in enumerate([
            'Searching for: willkg',
            '-----',
            'user_id',
            '-----'
    ]):
        assert output[i].startswith(starter)

    stdout = StringIO()
    call_command('finduser', 'jimbob', stdout=stdout)
    output = stdout.getvalue().splitlines()
    assert len(output) == 5
    for i, starter in enumerate([
            'Searching for: jimbob',
            '-----',
            'user_id  username',
            '%-5d    jimbob' % user.id,
    ]):
        print((i, output[i], starter))
        assert output[i].startswith(starter)


class TestMergeUser:
    def test_no_standupuser(self, db, django_user_model):
        """Test when keep and delete have no standup user"""
        user_keep = UserFactory.create(username='jimbob', email='jimbob@example.com')

# Path: standup/status/tests/factories.py
# class StandupUserFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.StandupUser'
# 
#     user = factory.SubFactory(UserFactory)
#     slug = factory.LazyAttribute(lambda obj: slugify(obj.user.username))
#     irc_nick = factory.Faker('user_name')
#     # FIXME: teams
# 
# class StatusFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.Status'
# 
#     created = fuzzy.FuzzyDateTime(
#         start_dt=datetime(2011, 9, 6, 0, 0, 0, tzinfo=pytz.utc)
#     )
#     user = factory.SubFactory(StandupUserFactory)
#     project = factory.SubFactory(ProjectFactory)
#     content = factory.Faker('sentence')
# 
# class TeamFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'status.Team'
#     name = factory.Faker('name')
#     slug = factory.LazyAttribute(lambda obj: slugify(obj.name))
# 
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = 'auth.User'
# 
#     username = factory.Faker('user_name')
#     first_name = factory.Faker('first_name')
#     last_name = factory.Faker('last_name')
#     email = factory.Faker('email')
#     password = factory.PostGenerationMethodCall('set_password', 'nopassword')
# 
#     is_active = True
#     is_staff = False
#     is_superuser = False


# Path: standup/status/tests/test_commands.py
from django.core.management import call_command
from django.utils.six import StringIO
from standup.status.tests.factories import (
    StandupUserFactory,
    StatusFactory,
    TeamFactory,
    UserFactory,
)
import pytest

    stdout = StringIO()
    call_command('finduser', 'willkg', stdout=stdout)
    output = stdout.getvalue().splitlines()
    assert len(output) == 4
    for i, starter in enumerate([
            'Searching for: willkg',
            '-----',
            'user_id',
            '-----'
    ]):
        assert output[i].startswith(starter)

    stdout = StringIO()
    call_command('finduser', 'jimbob', stdout=stdout)
    output = stdout.getvalue().splitlines()
    assert len(output) == 5
    for i, starter in enumerate([
            'Searching for: jimbob',
            '-----',
            'user_id  username',
            '%-5d    jimbob' % user.id,
    ]):
        print((i, output[i], starter))
        assert output[i].startswith(starter)


class TestMergeUser:
    def test_no_standupuser(self, db, django_user_model):
        """Test when keep and delete have no standup user"""
        user_keep = UserFactory.create(username='jimbob', email='jimbob@example.com')

        user_delete = UserFactory.create(username='jane', email='jane@example.com')