def test_job_generate_guid(self): guid = '1'*32 # Confirm that pre-assigned guids are not being overwritten. location = JobLocationFactory(guid=guid) self.assertEqual(guid, location.guid) location.delete() # Confirm that if a guid isn't assigned one is getting assigned # to it properly. location = JobLocationFactory() self.assertIsNotNone(location.guid) self.assertNotEqual(location.guid, guid)
def test_job_add_to_solr(self): job = JobFactory(owner=self.company, created_by=self.user) job.locations.add(JobLocationFactory()) job.add_to_solr() guids = " OR ".join(job.guids()) query = "guid:%s" % guids self.assertEqual(self.ms_solr.search(query).hits, 1)
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_job_generate_guid(self): guid = '1' * 32 # Confirm that pre-assigned guids are not being overwritten. location = JobLocationFactory(guid=guid) self.assertEqual(guid, location.guid) location.delete() # Confirm that if a guid isn't assigned one is getting assigned # to it properly. location = JobLocationFactory() self.assertIsNotNone(location.guid) self.assertNotEqual(location.guid, guid)
def test_purchased_job_add_to_solr(self): job = self.create_purchased_job() job.locations.add(JobLocationFactory()) job.save() # Add to solr and delete from solr shouldn't be called until # the job is approved. guids = " OR ".join(job.guids()) query = "guid:%s" % guids self.assertEqual(self.ms_solr.search(query).hits, 0) job.is_approved = True # Jobs won't be added/deleted until it's confirmed that the # purchased product is paid for as well. job.purchased_product.paid = True job.purchased_product.save() job.save() # Now that the job is approved, it should've been sent to solr. guids = " OR ".join(job.guids()) query = "guid:%s" % guids self.assertEqual(self.ms_solr.search(query).hits, 1)
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)