Esempio n. 1
0
File: tests.py Progetto: llou/Tedoy
 def setUp(self):
     self.jorge = TedoyUser(username="******")
     self.jorge.save()
     self.pepe = TedoyUser(username="******")
     self.pepe.save()
     self.juan = TedoyUser(username="******")
     self.juan.save()
     self.pedro = TedoyUser(username="******")
     self.pedro.save()
     self.jorge_music=self.jorge.main_group.create_subgroup('music')
     self.jorge_friends=self.jorge.main_group.create_subgroup('friends')
     self.pepe_friends=self.pepe.main_group.create_subgroup('friends')
     self.juan_friends=self.juan.main_group.create_subgroup('friends')
Esempio n. 2
0
File: tests.py Progetto: llou/Tedoy
 def test_security(self):
     viciana = TedoyUser(username="******")
     viciana.save()
     vice_group = self.jorge.main_group.create_subgroup('vice',public=False)
     vice_group.append(viciana)
     self.assertRaises(Forbidden,self.jorge.get_path,'vice',self.juan)
     self.assertRaises(Forbidden,self.jorge.get_path,'vice/viciana',self.juan)
     
     bieber = TedoyUser(username="******")
     bieber.save()
     bono = TedoyUser(username="******")
     bono.save()
     self.jorge_music.append(bieber,public=False)
     self.jorge_music.append(bono)
     self.assertRaises(Forbidden,self.jorge.get_path,'music/bieber',self.juan)
     self.assertEqual([self.jorge_music['user_donation_bono']],self.jorge_music.public_items())
Esempio n. 3
0
File: tests.py Progetto: llou/Tedoy
 def test_create_user(self):
     new_user = TedoyUser(username="******")
     new_user.save()
     self.assertTrue(isinstance(new_user.main_group,DonationGroup))
Esempio n. 4
0
File: tests.py Progetto: llou/Tedoy
class DonationsTest(TestCase):

    def setUp(self):
        self.jorge = TedoyUser(username="******")
        self.jorge.save()
        self.pepe = TedoyUser(username="******")
        self.pepe.save()
        self.juan = TedoyUser(username="******")
        self.juan.save()
        self.pedro = TedoyUser(username="******")
        self.pedro.save()
        self.jorge_music=self.jorge.main_group.create_subgroup('music')
        self.jorge_friends=self.jorge.main_group.create_subgroup('friends')
        self.pepe_friends=self.pepe.main_group.create_subgroup('friends')
        self.juan_friends=self.juan.main_group.create_subgroup('friends')

    def tearDown(self):
        self.jorge.delete()
        self.pepe.delete()
        self.juan.delete()
        self.pedro.delete()

    def test_basic_create_delete_groups(self):
        mg = self.jorge.main_group
        self.assertTrue(mg.main)
        mg.create_subgroup('prueba')
        prueba = mg['prueba']
        self.assertEqual(prueba,mg.subgroups.get(name="prueba"))
        self.assertEqual(prueba.path,[prueba])
        self.assertEqual(prueba.names_path,["prueba"])
        self.assertTrue(mg.has_key('prueba'))
        self.assertTrue(prueba,self.jorge.get_path('prueba',self.jorge))
        del mg['prueba']
        self.assertFalse(mg.has_key('prueba'))
    
    def test_create_delete_subgroups(self):
        mg = self.jorge.main_group
        music = mg['music']
        aviles = mg['friends']
        music.create_subgroup('Aviles')
        self.assertTrue(music.has_key('Aviles'))
        aviles = music['Aviles']
        self.assertEqual(self.jorge.get_path('music/Aviles',self.jorge),aviles)
        del music['Aviles']
        self.assertFalse(music.has_key('Aviles'))

    def test_donations_base(self):
        self.juan.main_group['friends'].append(self.pedro)
        self.pepe.main_group['friends'].append(self.juan.main_group['friends'])
        self.assertTrue(self.juan_friends.has_key('user_donation_pedro'))
        self.assertTrue(self.pepe_friends.has_key('subscribed_donation_juan_friends'))
        donation = UserDonation.objects.get(group=self.juan_friends,payee=self.pedro)
        self.assertEqual(donation,self.juan_friends['user_donation_pedro'])
        del self.juan_friends['user_donation_pedro']
        self.assertFalse(self.juan_friends.has_key('user_donation_pedro'))

    def test_security(self):
        viciana = TedoyUser(username="******")
        viciana.save()
        vice_group = self.jorge.main_group.create_subgroup('vice',public=False)
        vice_group.append(viciana)
        self.assertRaises(Forbidden,self.jorge.get_path,'vice',self.juan)
        self.assertRaises(Forbidden,self.jorge.get_path,'vice/viciana',self.juan)
        
        bieber = TedoyUser(username="******")
        bieber.save()
        bono = TedoyUser(username="******")
        bono.save()
        self.jorge_music.append(bieber,public=False)
        self.jorge_music.append(bono)
        self.assertRaises(Forbidden,self.jorge.get_path,'music/bieber',self.juan)
        self.assertEqual([self.jorge_music['user_donation_bono']],self.jorge_music.public_items())