def test__withdraw(test_teardown):
    """
    Basic test for removing applications
    """
    apply_external(user_id, url, position, company, resume, date_posted,
                   deadline, comment)
    applications = get_applications_external(user_id)
    assert len(applications) == 1

    # We delete the application
    withdraw_application(applications[0]['application_id'], user_id)
    applications = get_applications_external(user_id)
    assert len(applications) == 0
def test__apply(test_teardown):
    """
    Regular scenario for applying to external postings
    """

    # We create an application in the DB
    apply_external(user_id, url, position, company, resume, date_posted,
                   deadline, comment)
    applications = get_applications_external(user_id)

    assert len(applications) == 1
    assert applications[0]['user_id'] == user_id
    assert applications[0]['is_inhouse_posting'] == False
    assert applications[0]['url'] == url
    assert applications[0]['position'] == position
    assert applications[0]['company'] == company
    assert applications[0]['resume'] == resume
    assert applications[0]['application_id'] >= 0
def test__apply_with_missing_info(test_teardown):
    """
    Failure scenario: Missing information should throw errors.
    """
    user_id = "someid456"
    url, position, company = "", "", ""

    result = apply_external(user_id, url, position, company, resume,
                            date_posted, deadline, comment)
    assert result[
        'status'] == "You must provide a job URL, position and company."
def test__update_status_empty_string(test_teardown):
    """
    Failure scenario: Empty status should give an error
    """

    # We create an application in the DB
    applications = apply_external(user_id, url, position, company, resume,
                                  date_posted, deadline, comment)

    # We update the status of this application
    new_status = ""

    result = update_status(applications[0]['id'], new_status, user_id)
    assert result['status'] == "You must provide a non-empty new status."
def test__update_status(test_teardown):
    """
    Regular scenario for updating a status
    """
    new_status = "new!"

    # We create an application in the DB
    applications = apply_external(user_id, url, position, company, resume,
                                  date_posted, deadline, comment)
    updated_applications = update_status(applications[0]['id'], new_status,
                                         user_id)

    assert applications[0]['status'] != new_status
    assert updated_applications[0]['status'] == new_status
    assert updated_applications[0]['id'] == applications[0]['id']
Пример #6
0
def apply_external_endpoint():
  """
  Enables user to apply to an external job posting.

  Request body:
  - `url`: URL of the external posting
  - `position`: Job position of the external posting
  - `company`: Company where job takes place
  - `resume`: Handy tool for applying to jobs
  - `date_posted`: When the application was posted
  - `deadline`: Deadline to apply for the job
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  url, position, company = content.get("url", ""), content.get('position', ""), content.get('company', "")
  date_posted, deadline = content.get('date_posted', ""), content.get('deadline', "")
  resume, status, comment = content.get('resume', ""), content.get("status", "Applied"), content.get('comment', '')
  user_id = query_auth(headers['Authorization'])['_id']
  return jsonify(apply_external(user_id, url, position, company, resume,
                                date_posted, deadline, comment, status=status))