def test_newsletter_listing_returns_only_jg_if_enough(db_connection):
    job1 = create_job('1', source='juniorguru')
    job2 = create_job('2', source='moo')
    job3 = create_job('3', source='juniorguru')
    job4 = create_job('4', source='juniorguru')

    assert list(Job.newsletter_listing(3)) == [job1, job3, job4]
Beispiel #2
0
def test_newsletter_listing_backfills_up_to_min_count(db_connection):
    job1 = create_job('1', source='moo', sort_rank=5)
    job2 = create_job('2', source='foo', sort_rank=1)  # noqa
    job3 = create_job('3', source='bar', sort_rank=10)
    job4 = create_job('4', source='juniorguru')

    assert list(Job.newsletter_listing(3)) == [job4, job3, job1]
def test_newsletter_listing_returns_only_not_expired_jobs(db_connection):
    job1 = create_job('1', expires_at=None)
    job2 = create_job('2', expires_at=date(1987, 8, 30))
    job3 = create_job('3', expires_at=date.today())
    job4 = create_job('4', expires_at=date.today() + timedelta(days=2))

    assert set(Job.newsletter_listing(5)) == {job1, job4}
Beispiel #4
0
def test_newsletter_listing_returns_only_juniorguru_if_enough(db_connection):
    job1 = create_job('1', source='juniorguru', sort_rank=30)
    job2 = create_job('2', source='moo')  # noqa
    job3 = create_job('3', source='juniorguru', sort_rank=20)
    job4 = create_job('4', source='juniorguru', sort_rank=10)
    job5 = create_job('5', source='juniorguru', sort_rank=5)

    assert list(Job.newsletter_listing(3)) == [job1, job3, job4, job5]
Beispiel #5
0
def test_newsletter_listing_backfills_with_other_sources(db_connection):
    job1 = create_job('1', source='moo', sort_rank=20)
    job2 = create_job('2', source='foo', sort_rank=10)
    job3 = create_job('3', source='bar', sort_rank=40)
    job4 = create_job('4', source='juniorguru', sort_rank=30)
    job5 = create_job('5', source='juniorguru', sort_rank=20)

    assert list(Job.newsletter_listing(5)) == [job4, job5, job3, job1, job2]
def test_newsletter_listing_sorts_by_timestamp_asc(db):
    job1 = create_job('1', timestamp=datetime(2010, 7, 6, 20, 24, 3))
    job2 = create_job('2', timestamp=datetime(2019, 7, 6, 20, 24, 3))
    job3 = create_job('3', timestamp=datetime(2014, 7, 6, 20, 24, 3))

    assert list(Job.newsletter_listing()) == [job1, job3, job2]
def test_newsletter_listing_returns_only_jobs_not_sent(db):
    job1 = create_job('1', is_sent=True)
    job2 = create_job('2', is_sent=False)
    job3 = create_job('3', is_sent=True)

    assert set(Job.newsletter_listing()) == {job2}
def test_newsletter_listing_returns_only_approved_jobs(db):
    job1 = create_job('1', is_approved=True)
    job2 = create_job('2', is_approved=False)
    job3 = create_job('3', is_approved=True)

    assert set(Job.newsletter_listing()) == {job1, job3}
Beispiel #9
0
def admin_newsletter():
    with db:
        jobs = list(Job.newsletter_listing(10))
    return render_template('admin_newsletter.html', jobs=jobs)
Beispiel #10
0
def test_newsletter_listing_sorts_by_sort_rank_desc(db_connection, source):
    job1 = create_job('1', source=source, sort_rank=30)
    job2 = create_job('2', source=source, sort_rank=10)
    job3 = create_job('3', source=source, sort_rank=20)

    assert list(Job.newsletter_listing(5)) == [job1, job3, job2]
def test_newsletter_listing_sorts_by_posted_at_asc(db_connection):
    job1 = create_job('1', posted_at=datetime(2010, 7, 6, 20, 24, 3))
    job2 = create_job('2', posted_at=datetime(2019, 7, 6, 20, 24, 3))
    job3 = create_job('3', posted_at=datetime(2014, 7, 6, 20, 24, 3))

    assert list(Job.newsletter_listing()) == [job1, job3, job2]
def test_newsletter_listing_returns_only_jobs_not_sent(db_connection):
    job1 = create_job('1', newsletter_at=date.today() - timedelta(days=2))
    job2 = create_job('2', newsletter_at=None)
    job3 = create_job('3', newsletter_at=date.today() - timedelta(days=2))

    assert set(Job.newsletter_listing(5)) == {job2}
def test_newsletter_listing_returns_only_approved_jobs(db_connection):
    job1 = create_job('1', approved_at=date(1987, 8, 30))
    job2 = create_job('2', approved_at=None)
    job3 = create_job('3', approved_at=date(1987, 8, 30))

    assert set(Job.newsletter_listing(5)) == {job1, job3}