コード例 #1
0
    def test_election_update_with_a_celery_task(self):

        Election.fetch_all_from_api()

        UpdatingDataCandidator.install_candidator_yaml(yaml_file='candidator_example_data_with_answers2')

        election = Election.objects.all()[0]

        result = election_updater.delay(election)

        self.assertTrue(result.successful())

        juanito = Candidate.objects.all()[0]
        self.assertEquals(juanito.answers.all().count(), 4)
        
        
        
        marchas = Question.objects.get(question='Le gusta ir a las marchas?')
        self.assertEquals(juanito.answers.get(question=marchas).caption, u'Siempre')
        
        carretear = Question.objects.get(question='Quiere gastar su plata carreteando?')
        self.assertEquals(juanito.answers.get(question=carretear).caption, u'A veces')
        
        plata = Question.objects.get(question='Quiere robarse la plata del CEI?')
        self.assertEquals(juanito.answers.get(question=plata).caption, u'No')

        paros = Question.objects.get(question='Esta de a cuerdo con los paros?')
        self.assertEquals(juanito.answers.get(question=paros).caption, u'Estoy de acuerdo con algunos paros')
コード例 #2
0
 def update_election_from_candideit(self, request, queryset):
     for election in queryset:
         election_updater.delay(election)
コード例 #3
0
 def update_election_from_candideit(self, request, queryset):
     for election in queryset:
         election_updater.delay(election)