예제 #1
0
def test_render_jobs_weekly_campaign_job_record_template_only(create_jobs):
    jobs = get_jobs_from_last_week()
    # Comparing strings is tricky especially with newlines, we're not going to test the whole template,
    # anyway it has a lot of extras from mailchimp and too much noise
    expected_results = [
        '<a title="Experimental Particle Physics" href="https://labs.inspirehep.net/jobs/1444586">Experimental Particle Physics</a>\n(Beijing, Inst. High Energy Phys. - Asia) [Deadline:\n2019-09-01] POSTDOC - hep-ex, physics.ins-det\n(posted 5 days ago)',
        '<a title="Nuclear and Particle Physics" href="https://labs.inspirehep.net/jobs/1468124">Nuclear and Particle Physics</a>\n(U. Alabama, Tuscaloosa - North America) [Deadline:\n2019-08-01] POSTDOC - nucl-ex, hep-ex, physics.ins-det\n(posted 6 days ago)',
        '<a title="Experimental Particle Physics" href="https://labs.inspirehep.net/jobs/1616162">Experimental Particle Physics</a>\n(Shanghai Jiaotong U., INPAC - Asia) [Deadline:\n2019-09-30] POSTDOC - astro-ph, hep-ex, hep-lat, hep-ph, nucl-ex, physics.acc-ph, physics.ins-det\n(posted 7 days ago)',
    ]
    expected_results_len = 3
    assert expected_results_len == len(jobs)

    for job in jobs:
        result = render_template("mailing/jobs/weekly/item.html", job=job)
        assert result in expected_results
예제 #2
0
파일: cli.py 프로젝트: tsgit/inspirehep
def update_weekly_jobs():

    click.secho("Searching for jobs posted last week")

    jobs = get_jobs_from_last_week()
    if not jobs:
        click.secho("No jobs found from last week skipping...", fg="red")
        return

    click.secho(f"Found {len(jobs)} job records from last week.", fg="green")

    content = get_jobs_weekly_html_content(jobs)
    if not mailtrain_update_weekly_campaign_content(content):
        click.secho("There was a problem with updating Atom Feed")
        exit(1)

    click.secho("Campaign updated.", fg="green")
예제 #3
0
def test_jobs_from_last_week_empty(base_app, db, es_clear):
    expected_control_numbers = []

    results = get_jobs_from_last_week()
    assert expected_control_numbers == []
예제 #4
0
def test_jobs_from_last_week(base_app, db, es_clear, create_jobs):
    expected_control_numbers = [1444586, 1468124, 1616162]

    results = get_jobs_from_last_week()
    results_control_numbers = [result["control_number"] for result in results]
    assert expected_control_numbers == results_control_numbers
예제 #5
0
def test_jobs_from_last_week_empty(inspire_app):
    expected_control_numbers = []

    results = get_jobs_from_last_week()
    assert expected_control_numbers == []