def test_change_job_application_state(self):
        """Test case for change_job_application_state

        Changes a state of a job application by its id.
        """
        test_job_application = TestDataGenerator.get_job_application()
        application_id = test_job_application['_id'] = get_next_id(
            'applicationId')
        application.db.job_applications.insert_one(test_job_application)

        body = {'state': JobApplicationState.ACTIVE}
        response = self.client.open(
            '/marketplace/jobApplications/{id}/changeState'.format(
                id=application_id),
            method='PUT',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

        response_body = json.loads(
            self.client.open(
                '/marketplace/jobApplications/{id}'.format(id=application_id),
                method='GET').data.decode('utf-8'))
        self.assertEqual(response_body['state'], body['state'])
Exemple #2
0
    def test_update_job_offer(self):
        job_offer = TestDataGenerator.get_job_offer()
        job_offer_id = job_offer['_id'] = get_next_id('offerId')
        job_offer['state'] = JobOfferState.OPEN
        application.db.job_offers.insert_one(job_offer)

        query = {'_id': job_offer_id}
        new_state = JobOfferState.COMPLETED
        JobOfferService.update_job_offer(query, new_state)

        updated = application.db.job_offers.find_one(query)
        self.assertEqual(new_state, updated['state'])
    def create_job_offer(dto: CreateJobOfferDto) -> dict:
        job_offer = JobOffer.from_dto(dto)
        job_offer.poster = ExternalServices.get_user_info(dto.poster_id)
        job_offer.state = JobOfferState.OPEN
        job_offer.date_created = datetime.now()

        json = job_offer.to_dict()
        json['_id'] = get_next_id("offerId")
        application.db.job_offers.insert_one(json)
        json = remap_id(json)
        ExternalServices.publish_to_message_queue(QueueMessageType.JOB_OFFER_CREATED, json)
        return json
Exemple #4
0
    def test_update_job_application(self):
        job_application = TestDataGenerator.get_job_application()
        job_application_id = job_application['_id'] = get_next_id(
            'applicationId')
        job_application['state'] = JobApplicationState.NEW
        application.db.job_applications.insert_one(job_application)

        query = {"_id": job_application_id}
        new_state = JobApplicationState.ACCEPTED
        JobApplicationService.update_job_application(query,
                                                     {'state': new_state})

        actual = application.db.job_applications.find_one(query)
        self.assertEqual(new_state, actual['state'])
    def create_job_application(dto: CreateJobApplicationDto) -> dict:
        offer = application.db.job_offers.find_one({'_id': dto.job_offer_id})
        if offer is None:
            raise RestException("errors.job_offers.not_found", 404)

        job_application = JobApplication.from_dto(dto)
        job_application.state = JobApplicationState.NEW
        job_application.date_created = datetime.now()
        job_application.applicant = ExternalServices.get_user_info(
            dto.applicant_id)

        json = job_application.to_dict()
        json['_id'] = get_next_id("applicationId")
        application.db.job_applications.insert_one(json)
        return remap_id(json)
Exemple #6
0
    def test_update_job_offer(self):
        """Test case for update_job_offer

        Updates a job offer by its id.
        """
        test_job_offer = TestDataGenerator.get_job_offer()
        offer_id = test_job_offer['_id'] = get_next_id('offerId')
        test_job_offer['state'] = JobOfferState.OPEN
        application.db.job_offers.insert_one(test_job_offer)
        body = {"state": JobOfferState.WITHDRAWN}

        response = self.client.open(
            '/marketplace/jobOffers/{id}'.format(id=offer_id),
            method='PUT',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

        response_object = json.loads(
            self.client.open('/marketplace/jobOffers/{id}'.format(id=offer_id),
                             method='GET').data.decode('utf-8'))

        self.assertEqual(body["state"], response_object["state"])
Exemple #7
0
    def test_get_job_offer(self):
        """Test case for get_job_offer

        Gets a job offer by its id.
        """
        test_job_offer = TestDataGenerator.get_job_offer()
        offer_id = test_job_offer['_id'] = get_next_id('offerId')
        application.db.job_offers.insert_one(test_job_offer)

        response = self.client.open(
            '/marketplace/jobOffers/{id}'.format(id=offer_id), method='GET')
        response_string = response.data.decode('utf-8')
        self.assert200(response, 'Response body is : ' + response_string)
        response_object = json.loads(response_string)

        self.assertEqual(test_job_offer["companyName"],
                         response_object["companyName"])
        self.assertEqual(test_job_offer["description"],
                         response_object["description"])
        self.assertEqual(test_job_offer["positionName"],
                         response_object["positionName"])
        self.assertEqual(test_job_offer["poster"]["id"],
                         response_object["poster"]["id"])
        self.assertEqual(test_job_offer["_id"], response_object["id"])
    def test_update_job_application(self):
        """Test case for update_job_application

        Updates an application by its id.
        """
        test_job_application = TestDataGenerator.get_job_application()
        application_id = test_job_application['_id'] = get_next_id(
            'applicationId')
        application.db.job_applications.insert_one(test_job_application)

        body = {'note': "Hello I have 3 years experience."}
        response = self.client.open(
            '/marketplace/jobApplications/{id}'.format(id=application_id),
            method='PUT',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

        response_body = json.loads(
            self.client.open(
                '/marketplace/jobApplications/{id}'.format(id=application_id),
                method='GET').data.decode('utf-8'))
        self.assertEqual(response_body['note'], body['note'])