Esempio n. 1
0
    def save(self, *args, **kwargs):

        if self.api_instance_id is None or self.writeitinstance_id is None:
            writeit_instance = get_writeit_instance()
            self.api_instance = writeit_instance.api_instance
            self.writeitinstance = writeit_instance
        super(VotaInteligenteMessage, self).save(*args, **kwargs)
 def setUp(self):
     self.instance = get_writeit_instance()
     self.election = Election.objects.get(id=1)
     self.candidate1 = Candidate.objects.get(id=4)
     self.candidate2 = Candidate.objects.get(id=5)
     self.candidate3 = Candidate.objects.get(id=6)
     self.message = VotaInteligenteMessage.objects.create(election=self.election,
                                                     author_name='author',
                                                     author_email='*****@*****.**',
                                                     subject='subject',
                                                     content='content',
                                                     slug='subject-slugified',
                                                     moderated=True
                                                     )
     self.message.people.add(self.candidate1)
     self.message.people.add(self.candidate2)
 def setUp(self):
     self.instance = get_writeit_instance()
     self.election = Election.objects.get(id=1)
     self.candidate1 = Candidate.objects.get(id=4)
     self.candidate2 = Candidate.objects.get(id=5)
     self.candidate3 = Candidate.objects.get(id=6)
 def test_get_writeit_instance_from_globally_set_variables(self):
     '''There is a function that returns a writeit instance where to push messages'''
     instance = get_writeit_instance()
     self.assertEquals(instance.name, 'votainteligente')
     self.assertEquals(instance.url, "/api/v1/instance/1/")
     self.assertEquals(instance.api_instance.url, 'http://writeit.ciudadanointeligente.org')