'Test User model'

def test_model_User_profile(self):

    username = 'testusername'
    password = 'password'
    user = DjangoUser(username=username)
    user.set_password(password)
    user.save()
    self.assertEquals(user.username, username)
    self.assertIsNotNone(user.id)
    profile = user.profile
    self.assertEquals(profile.name, username)
    self.assertEquals(profile.default_group, Group.objects.all()[0])
    self.assertQuerysetEqual(profile.other_groups.all(), [])
    self.assertFalse(profile.disabled)
    self.assertTrue(((profile.last_access - datetime.datetime.now()) < datetime.timedelta(seconds=1)))
    self.assertEqual(profile.get_absolute_url(), '/contacts/user/view/{}'.format(profile.id))
    oldpsw = profile.user.password
    self.assertNotEqual(profile.generate_new_password(), oldpsw)
    self.assertQuerysetEqual(profile.get_groups(), map(repr, [profile.default_group]))
    self.assertTrue(profile.is_admin())
    self.assertEqual(profile.get_username(), username)
    self.assertEqual(profile.get_perspective(), Perspective.objects.get(name='Default'))
    self.assertEqual(profile.get_contact(), Contact.objects.get(related_user=profile))
    self.assertTrue(profile.has_contact())
    self.assertEqual(profile.__unicode__(), username)
