def test_add_advert_to_invalid_job(self): job_id = "RANDOM" with self.assertRaisesRegex( ValueError, 'The job with id `{job_id}` has not been found'.format( job_id=job_id)): add_advert_to_job(job_id=job_id, advert_duration_days=15)
def setUp(self): super().setUp() self.days = 15 add_advert_to_job(job_id=self.job_id, advert_duration_days=self.days) self.advert = add_advert_to_job(job_id=self.job_id, advert_duration_days=self.days) add_advert_to_job(job_id=self.job_id, advert_duration_days=self.days) self.advert_id = self.advert['_id']
def test_get_advert_applications_by_job_id(self): job = self.create_from_factory(JobFactory) advert_1 = add_advert_to_job(job_id=job['_id'], advert_duration_days=19) advert_2 = add_advert_to_job(job_id=job['_id'], advert_duration_days=19) apply_advert(advert_id=advert_1['_id'], **self.candidate) apply_advert(advert_id=advert_2['_id'], **self.candidate) applications = get_advert_applications_by_job_id(job_id=job['_id']) self.assertEqual([self.candidate, self.candidate], applications['candidates'])
def test_add_job_advert(self): days = 15 add_advert_to_job(job_id=self.job_id, advert_duration_days=days) stored_job = get_job(job_id=self.job_id) stored_adverts = stored_job['adverts'] self.assertEquals(1, len(stored_adverts)) stored_advert = stored_adverts[0] self.assertEquals(AdvertStatus.DRAFT, stored_advert['status']) self.assertEquals(days, stored_advert['duration'])
def _create_approved_advert(self): job = self.create_from_factory(JobFactory) job_id = job['_id'] advert = add_advert_to_job(job_id=job_id, advert_duration_days=15) advert_id = advert['_id'] request_approval_job_advert(job_id=job_id, advert_id=advert_id) approve_job_advert(job_id=job_id, advert_id=advert_id) return job_id, advert_id
def _crate_job(cls, **job_args): job = cls.create_from_factory(JobFactory, **job_args) job_id = job['_id'] advert = add_advert_to_job(job_id=job_id, advert_duration_days=15) advert_id = advert['_id'] request_approval_job_advert(job_id=job_id, advert_id=advert_id) approve_job_advert(job_id=job_id, advert_id=advert_id) publish_job_advert(job_id=job_id, advert_id=advert_id) return job
def test_edit_job_not_allowed_if_draft_and_not_admin(self): self._user = self.create_from_factory( UserFactory, user_type=UserType.HIRING_MANAGER) data = {"title": "new title"} job_id = self.job['_id'] advert = add_advert_to_job(job_id=job_id, advert_duration_days=19) approve_job_advert(job_id=job_id, advert_id=advert['_id']) url = self.url_for_admin(JOB_URL, job_id=job_id) response = self.post_json(url, data) self.assertEqual(400, response.status_code) self.assertEqual( loads(response.data)['message'], "User not allowed to edit an approved advert")
def _crate_job(cls, duration=15, published=True, expired=False, **job_args): job = cls.create_from_factory(JobFactory, **job_args) job_id = job['_id'] advert = add_advert_to_job(job_id=job_id, advert_duration_days=duration) advert_id = advert['_id'] request_approval_job_advert(job_id=job_id, advert_id=advert_id) approve_job_advert(job_id=job_id, advert_id=advert_id) if published: publish_job_advert(job_id=job_id, advert_id=advert_id) if expired: cls._make_advert_expired(job_id=job_id, advert_id=advert_id) return job
def _add_advert(self, job_id): advert = add_advert_to_job(job_id=job_id, advert_duration_days=10) return advert
def _create_job_with_advert(self): job = self.create_from_factory(JobFactory) advert = add_advert_to_job(job_id=job['_id'], advert_duration_days=10) return job, advert
def api_add_advert_to_job(job_id: str): data = request.json duration = data.get('duration') return add_advert_to_job(job_id=job_id, advert_duration_days=duration)
def setUp(self): super().setUp() self.job = self.create_from_factory(JobFactory) self.job_id = self.job['_id'] self.advert = add_advert_to_job(job_id=self.job_id, advert_duration_days=15)