Exemple #1
0
 def test_relationship_exists(self):
     #
     # Create users
     #
     user1 = User.objects.create_user('user1', '*****@*****.**', 'abc123',
                                      name='User 1')
     user2 = User.objects.create_user('user2', '*****@*****.**', 'abc123',
                                      name='User 2')
     #
     # Create relationship
     #
     rel1 = Friendship()
     rel1.owner = user1
     rel1.friend = user2
     rel1.save()
     #
     # Create other relationship
     #
     rel2 = Friendship()
     rel2.owner = user1
     rel2.friend = user2
     #
     # Test clean
     #
     self.assertRaises(ValidationError, rel2.clean)
Exemple #2
0
 def test_relationship_unicode(self):
     #
     # Create user
     #
     owner = User.objects.create_user('user1', '*****@*****.**', 'Pwd007',
                                      name='User 1')
     to = User.objects.create_user('user2', '*****@*****.**', 'secret',
                                   name='User 2')
     #
     # Relationship
     #
     rel = Friendship()
     rel.owner = owner
     rel.friend = to
     #
     # Test
     #
     self.assertEqual(unicode(rel), '{} -> {}'.format(unicode(owner),
                                                      unicode(to)))
Exemple #3
0
 def test_relationship_clean(self):
     #
     # Create user
     #
     user = User()
     user.name = 'FlusFlis'
     user.username = '******'
     user.email = '*****@*****.**'
     user.set_password('Fr3nCh')
     user.is_active = True
     user.save()
     #
     # Create relationship
     #
     rel = Friendship()
     rel.owner = user
     rel.friend = user
     #
     # Test clean
     #
     self.assertRaises(ValidationError, rel.clean)