from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.test import TestCase
import factory

from imager_profile.models import ImagerProfile

# Create your tests here.


class UserFactory(factory.Factory):
    class Meta:
        model = User

    username = factory.Sequence(lambda n: "user{}".format(n))
    email = factory.Sequence(lambda n: "user{}@example.com".format(n))


class ProfileTestCases(TestCase):

    def setup(self):
        self.user = UserFactory.build()

    def test_profile_is_created_when_used_is_saved(self):
        self.assertTrue(ImagerProfile.objects.count() == 0)
        self.user.save()
        self.assertTrue(ImagerProfile.objects.count() == 1)

    def test_profile_str_is_user_username(self):
        self.user.save()
        profile = ImagerProfile.objects.get(user=self.user)
        self.assertEqual(str(profile), self.user.username)

@@ -135,22 +135,8 @@
 rom 
-imager_profile
 .mod
@@ -165,35 +165,8 @@
 le%0A%0A
-# Create your tests here.%0A%0A
 %0Acla
@@ -392,17 +392,16 @@
 TestCase
-s
 (TestCas
@@ -416,17 +416,17 @@
  def set
-u
+U
 p(self):
@@ -465,16 +465,98 @@
 .build()
+%0A        self.user1 = UserFactory.build()%0A        self.user2 = UserFactory.build()
 %0A%0A    de
@@ -589,17 +589,17 @@
 when_use
-d
+r
 _is_save
@@ -684,32 +684,58 @@
 elf.user.save()%0A
+        self.user2.save()%0A
         self.ass
@@ -775,17 +775,17 @@
 nt() == 
-1
+2
 )%0A%0A    d
@@ -972,8 +972,326 @@
 ername)%0A
+%0A    def test_profile_is_active(self):%0A        self.user.save()%0A        self.profile = ImagerProfile.objects.all()%5B0%5D%0A        self.assertTrue(self.profile.is_active)%0A%0A    def test_profile_is_deleted(self):%0A        self.user.save()%0A        self.user.delete()%0A        self.assertTrue(ImagerProfile.objects.count() == 0)%0A

modify test