# 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
        StatusFactory.create(user=standupuser_keep, content='1'),
        StatusFactory.create(user=standupuser_keep, content='2'),
        StatusFactory.create(user=standupuser_keep, content='3'),

        user_delete = UserFactory.create(username='jane', email='jane@example.com')
        standupuser_delete = StandupUserFactory.create(user=user_delete)
        StatusFactory.create(user=standupuser_delete, content='4'),
        StatusFactory.create(user=standupuser_delete, content='5'),
        StatusFactory.create(user=standupuser_delete, content='6'),

        stdout = StringIO()
        call_command('mergeuser', keep=user_keep.id, delete=user_delete.id, assume_yes=True, stdout=stdout)
        output = stdout.getvalue()
        print(output)

        # Verify all statuses were transfered from delete to keep
        user_keep = django_user_model.objects.get(id=user_keep.id)
        statuses = [status.content for status in user_keep.profile.statuses.all()]
        assert sorted(statuses) == ['1', '2', '3', '4', '5', '6']

        # Verify email address was transferred from delete -> keep
        assert user_keep.email == 'jane@example.com'

        # Verify delete no longer exists
        with pytest.raises(django_user_model.DoesNotExist):
            django_user_model.objects.get(id=user_delete.id)

    def test_teams(self, db, django_user_model):
        """Verify teams get carried over"""
        team1 = TeamFactory.create()

# 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

        StatusFactory.create(user=standupuser_keep, content='1'),
        StatusFactory.create(user=standupuser_keep, content='2'),
        StatusFactory.create(user=standupuser_keep, content='3'),

        user_delete = UserFactory.create(username='jane', email='jane@example.com')
        standupuser_delete = StandupUserFactory.create(user=user_delete)
        StatusFactory.create(user=standupuser_delete, content='4'),
        StatusFactory.create(user=standupuser_delete, content='5'),
        StatusFactory.create(user=standupuser_delete, content='6'),

        stdout = StringIO()
        call_command('mergeuser', keep=user_keep.id, delete=user_delete.id, assume_yes=True, stdout=stdout)
        output = stdout.getvalue()
        print(output)

        # Verify all statuses were transfered from delete to keep
        user_keep = django_user_model.objects.get(id=user_keep.id)
        statuses = [status.content for status in user_keep.profile.statuses.all()]
        assert sorted(statuses) == ['1', '2', '3', '4', '5', '6']

        # Verify email address was transferred from delete -> keep
        assert user_keep.email == 'jane@example.com'

        # Verify delete no longer exists
        with pytest.raises(django_user_model.DoesNotExist):
            django_user_model.objects.get(id=user_delete.id)

    def test_teams(self, db, django_user_model):
        """Verify teams get carried over"""
        team1 = TeamFactory.create()

        team2 = TeamFactory.create()