Exemplo n.º 1
0
 def test_trophies_retrieval_from_mep(self):
     """
     Test that meps' CouchDB model can retrieve associated Django trophies.
     """
     # Initialization
     a_mep = MEP.get('AlainLipietz')
     manual_trophy = ManualTrophy.objects.create(label="A manual trophy")
     auto_trophy = AutoTrophy.objects.create(label="An auto trophy")
     self.failUnlessEqual(a_mep.trophies, [])
     
     # Let's create a reward and attribute it to verify CouchDB's update
     reward = Reward.objects.create(mep_wikiname=a_mep._id, trophy=manual_trophy, reason="test")
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(repr(a_mep.trophies), "[<ManualTrophy: A manual trophy>]")
     
     # OK, now we verify that deletion is triggered to CouchDB
     reward.delete()
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies, [])
Exemplo n.º 2
0
 def test_trophies_attribution(self):
     """
     Test that trophies' models can interact with CouchDB.
     """
     # Initialization
     a_mep = MEP.get('AlainLipietz')
     manual_trophy = ManualTrophy.objects.create(label="A manual trophy")
     auto_trophy = AutoTrophy.objects.create(label="An auto trophy")
     self.failUnlessEqual(a_mep.trophies_ids, [])
     
     # Let's create a reward and attribute it to verify CouchDB's update
     reward = Reward.objects.create(mep_wikiname=a_mep._id, trophy=manual_trophy, reason="test")
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies_ids, [1])
     
     # OK, now we verify that deletion is triggered to CouchDB
     reward.delete()
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies_ids, [])
Exemplo n.º 3
0
 def setUp(self):
     # Delete all trophies for the test user
     a_mep = MEP.get('AlainLipietz')
     a_mep.trophies_ids = []
     a_mep.save()