Exemple #1
0
def test_job_slug_model_mixin():
    job = Job()
    assert job.slug is None

    job.populate_slug()
    assert job.slug is None

    job.title = u'test'
    job.populate_slug()
    assert job.slug == u'test'

    job.title = u'test1'
    job.populate_slug()
    assert job.slug == u'test1'
Exemple #2
0
def job(company, location):
    return Job(title=u'testfoo',
               description=u'testfoo',
               contact_method=1,
               remote_work=False,
               company=company,
               location=location,
               job_type=1,
               recruiter_name=u'jon',
               recruiter_email=u'doe')
Exemple #3
0
def test_job_model(company, location, session):
    title = u'ríbëyé'
    recruiter_name = u'相'
    recruiter_email = u'思'

    job = Job(title=title,
              description=title,
              contact_method=1,
              remote_work=False,
              company=company,
              location=location,
              job_type=1,
              recruiter_name=recruiter_name,
              recruiter_email=recruiter_email)

    session.add(job)
    session.commit()

    assert job.id > 0
    assert not job.published
    assert job.company_id == company.id
    assert job.company.id == company.id
    assert job.location_id == location.id
    assert job.location.id == location.id
    assert job.title == title
    assert job.description == title
    assert job.contact_method == 1
    assert job.job_type == 1
    assert job.slug == normalize('NFKD', title)
    assert str(job.id) in job.url()
    assert job.company.slug in job.url()
    assert 'http' not in job.url()
    assert str(job.id) in job.url(external=True)
    assert job.company.slug in job.url(external=True)
    assert 'http' in job.url(external=True)
    assert str(job.id) in job.edit_url() and job.admin_token in job.edit_url()
    assert job.recruiter_name == recruiter_name
    assert job.recruiter_email == recruiter_email
    assert job.created <= now()

    # Check if we get `arrow` dates back.
    assert type(job.created) is Arrow
Exemple #4
0
def job(company, location):
    return Job(
        title=u'foo',
        description=u'foo',
        contact_method=1,
        remote_work=False,
        company=company,
        location=location,
        job_type=1,
        recruiter_name=u'foo bar',
        recruiter_email=u'*****@*****.**'
    )
Exemple #5
0
def test_adding_tag(session, company, location):
    one = Tag(tag=u'one')

    # Test adding tags via the constructor, hence not using the fixture.
    job = Job(title=u'foo',
              description=u'foo',
              contact_method=1,
              remote_work=False,
              company=company,
              location=location,
              job_type=1,
              recruiter_name=u'foo bar',
              recruiter_email=u'*****@*****.**',
              tags=[one])

    # Try to add one existing and two new tags.
    tags = job.add_tags([u'one', u'two', u'three'])

    session.add(job)
    session.commit()

    assert len(job.tags) == 3
    for tag in tags:
        assert tag in job.tags
Exemple #6
0
def main(session, app):
    kwargs = dict()
    next = 'title'

    while next:
        field = field_schema[next]
        message = field['prompt']
        handler = field.get('handler')
        value = prompt(message)
        if handler:
            value = handler(value, session)
        kwargs[next] = value
        next = field.get('next')
        if hasattr(next, '__call__'):
            next = next(value)

    job = Job(**kwargs)
    session.add(job)
Exemple #7
0
def test_duplicate_job_model(company, location, session):
    title = u'foobar'

    for _ in range(3):
        job = Job(title=title,
                  description=title,
                  contact_method=1,
                  remote_work=False,
                  company=company,
                  location=location,
                  job_type=1,
                  recruiter_name=u'Αλέκος',
                  recruiter_email=u'alekos@Κόκοτας.com')

        session.add(job)
        session.commit()

        assert job.id > 0
        assert job.title == title
Exemple #8
0
def test_job_model_contact_method_validator():
    with pytest.raises(ValueError):
        Job(title='', description='', contact_method=10,
            remote_work='', company_id=0, job_type=1)
Exemple #9
0
def test_job_model_job_type_validator():
    with pytest.raises(ValueError):
        Job(title='', description='', contact_method=1,
            remote_work='', company_id=0, job_type=10,
            recruiter_name='a', recruiter_email='a')
Exemple #10
0
def populate_job(form, job=None):
    """Populates a `Job` model from a `JobForm` object.

    :param form: A `JobForm` instance.

    """
    if job is None:
        job = Job()

    form_data = form.data

    job.title = form_data['title']
    job.description = form_data['description']
    job.job_type = form_data['job_type']
    job.contact_method = form_data['contact_method']
    job.remote_work = form_data['remote_work']

    job.replace_tags(form_data['tags'])

    job.recruiter_name = form_data['recruiter_name']
    job.recruiter_email = form_data['recruiter_email']

    job.populate_slug()

    if job.contact_method == 1:
        job.contact_url = form_data['contact_url']
    else:
        job.contact_email = form_data['contact_email']

    populate_company(job, form_data)
    populate_location(job, form_data)

    return job