def test_job_remove_from_solr(self): job = JobFactory(owner=self.company, created_by=self.user) locations = JobLocationFactory.create_batch(2) job.locations = locations job.save() job.remove_from_solr() guids = " OR ".join(job.guids()) query = "guid:%s" % guids self.assertEqual(self.ms_solr.search(query).hits, 0)
def test_job_creation_and_deletion(self): locations = JobLocationFactory.create_batch(5) job = JobFactory(owner=self.company, created_by=self.user) job.locations = locations job.save() self.assertEqual(Job.objects.all().count(), 1) self.assertEqual(JobLocation.objects.all().count(), 5) job.delete() self.assertEqual(Job.objects.all().count(), 0) self.assertEqual(JobLocation.objects.all().count(), 0)
def test_add_remove_job_locations(self): """ Regression test, job locations that were removed from a job weren't being removed from Solr Tests that adding or removing locations results in Solr updates after a job save """ locations = JobLocationFactory.create_batch(2) job = JobFactory( owner=self.company, created_by=self.user, locations=locations) self.assertEqual(self.ms_solr.search('*:*').hits, 2) guid = locations[0].guid job.locations.remove(locations[0]) self.assertEqual(self.ms_solr.search('guid:%s' % guid).hits, 0) self.assertEqual(self.ms_solr.search('guid:%s' % locations[1].guid).hits, 1) job.locations.remove(locations[1]) self.assertEqual(self.ms_solr.search('*:*').hits, 0)
def test_add_remove_job_locations(self): """ Regression test, job locations that were removed from a job weren't being removed from Solr Tests that adding or removing locations results in Solr updates after a job save """ locations = JobLocationFactory.create_batch(2) job = JobFactory(owner=self.company, created_by=self.user, locations=locations) self.assertEqual(self.ms_solr.search('*:*').hits, 2) guid = locations[0].guid job.locations.remove(locations[0]) self.assertEqual(self.ms_solr.search('guid:%s' % guid).hits, 0) self.assertEqual( self.ms_solr.search('guid:%s' % locations[1].guid).hits, 1) job.locations.remove(locations[1]) self.assertEqual(self.ms_solr.search('*:*').hits, 0)