def test_validate_company_id(self):
        input_job = self._get_test_create_job_input()
        input_job['company_id'] = "SOMETHING"

        with self.assertRaisesRegex(
                ValueError, 'The company_id `{company_id}` is invalid'.format(
                    company_id=input_job['company_id'])):
            create_job(**input_job)
    def test_validate_location(self):
        input_job = self._get_test_create_job_input()
        input_job['location']['latitude'] = 10000

        with self.assertRaisesRegex(
                ValueError,
                'Latitude value have to be -90 <= latitude <= 90'):
            create_job(**input_job)
Esempio n. 3
0
    def create(self, **qwargs):

        default_values = load_example_model(self.EXAMPLE_MODEL_NAME)

        if 'company_id' not in qwargs:
            company = self.create_from_factory(CompanyFactory)
            default_values['company_id'] = company['_id']

        default_values.update(qwargs)

        return create_job(**default_values)
Esempio n. 4
0
def api_create_job():
    data = request.json

    validate('create_job', data)

    return create_job(**data)
    def test_create_job(self):
        input_job = self._get_test_create_job_input()
        created_job = create_job(**input_job)

        stored_job = get_job(created_job['_id'])
        self.assert_validate_json_schema('job', stored_job)