Exemplo n.º 1
0
 def test_do_the_pulling(self):
     '''Actually do the pulling from popit in an asynchronous way'''
     Person.objects.all().delete()
     writeitinstance = WriteItInstance.objects.create(name='instance 1', slug='instance-1', owner=self.owner)
     WriteitInstancePopitInstanceRecord.objects.create(
         writeitinstance=writeitinstance,
         popitapiinstance=self.api_instance1
         )
     pull_from_popit.delay(writeitinstance, self.api_instance1)  # Returns result
     self.assertTrue(writeitinstance.persons.all())
Exemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        writeitinstance = get_object_or_404(WriteItInstance,
            slug=self.request.subdomain,
            owner=self.request.user)
        popits_previously_related = PopitApiInstance.objects.filter(
            writeitinstancepopitinstancerecord__writeitinstance=writeitinstance)

        popit_api_instance = get_object_or_404(popits_previously_related, pk=kwargs['popit_api_pk'])
        pull_from_popit.delay(writeitinstance, popit_api_instance)
        return HttpResponse()
Exemplo n.º 3
0
 def test_do_the_pulling(self):
     '''Actually do the pulling from popit in an asynchronous way'''
     Person.objects.all().delete()
     writeitinstance = WriteItInstance.objects.create(name='instance 1',
                                                      slug='instance-1',
                                                      owner=self.owner)
     WriteitInstancePopitInstanceRecord.objects.create(
         writeitinstance=writeitinstance,
         popitapiinstance=self.api_instance1)
     pull_from_popit.delay(writeitinstance,
                           self.api_instance1)  # Returns result
     self.assertTrue(writeitinstance.persons.all())
Exemplo n.º 4
0
 def load_persons_from_a_popit_api(self, popit_url):
     '''This is an async wrapper for getting people from the api'''
     popit_api_instance, created = PopitApiInstance.objects.get_or_create(
         url=popit_url)
     record, created = WriteitInstancePopitInstanceRecord.objects.get_or_create(
         writeitinstance=self, popitapiinstance=popit_api_instance)
     if not created:
         record.updated = datetime.datetime.today()
         record.save()
     record.set_status('inprogress')
     from nuntium.tasks import pull_from_popit
     return pull_from_popit.delay(self, popit_api_instance)
Exemplo n.º 5
0
 def load_persons_from_a_popit_api(self, popit_url):
     '''This is an async wrapper for getting people from the api'''
     popit_api_instance, created = PopitApiInstance.objects.get_or_create(url=popit_url)
     record, created = WriteitInstancePopitInstanceRecord.objects.get_or_create(
         writeitinstance=self,
         popitapiinstance=popit_api_instance
         )
     if not created:
         record.updated = datetime.datetime.today()
         record.save()
     record.set_status('inprogress')
     from nuntium.tasks import pull_from_popit
     return pull_from_popit.delay(self, popit_api_instance)