コード例 #1
0
ファイル: tests.py プロジェクト: Gu1/memopol-core
 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, [])
コード例 #2
0
ファイル: tests.py プロジェクト: Gu1/memopol-core
 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, [])
コード例 #3
0
ファイル: update_meps.py プロジェクト: Gu1/memopol-core
def create_mep(mep_json):
    mep = MEP()
    mep.id = create_uniq_id(mep_json)
    mep.picture = mep.id + ".jpg"
    mep.active = True
    change_mep_details(mep, mep_json)
    add_missing_details(mep, mep_json)
    if mep_json.get("Addresses"):
        add_addrs(mep, mep_json["Addresses"])
    mep.save()
    add_committees(mep, mep_json.get("Committees", []))
    add_delegations(mep, mep_json.get("Delegations", []))
    add_countries(mep, mep_json["Constituencies"])
    add_groups(mep, mep_json.get("Groups",[]))
    add_assistants(mep, mep_json.get("assistant", []))
    add_organizations(mep, mep_json.get("Staff", []))
    if mep_json.get("Mail"):
        add_mep_email(mep, mep_json["Mail"])

    if mep_json.get("Homepage"):
        add_mep_website(mep, mep_json["Homepage"] + mep_json.get("Twitter", []) + mep_json.get("Facebook", []))
    add_mep_cv(mep, mep_json.get("CV", []))
    print "     save mep modifications"
    mep.save()
コード例 #4
0
ファイル: tests.py プロジェクト: Gu1/memopol-core
 def setUp(self):
     # Delete all trophies for the test user
     a_mep = MEP.get('AlainLipietz')
     a_mep.trophies_ids = []
     a_mep.save()