def test_create_message_expires_soon(logo_mock, template):
    logo_mock.expires_at = date(2020, 7, 1)
    message = create_message(logo_mock, template, date(2020, 6, 24))
    html = message['html_content']

    assert 'Prodlužte' in html
    assert 'https://junior.guru/hire-juniors/#handbook' in html
def test_create_message_job_slots_zero(logo_mock, template):
    logo_mock.job_slots = 0
    message = create_message(logo_mock, template, date(2020, 6, 23))
    html = message['html_content']

    assert 'paušál' not in html
    assert 'inzerát' not in html
def test_create_message_clicks_non_zero(logo_mock, template):
    logo_mock.metrics = dict(users=15, pageviews=25, clicks=5)
    message = create_message(logo_mock, template, date(2020, 6, 23))
    html = message['html_content']

    assert 'kliknutí' in html
    assert '<b>5</b>' in html
def test_create_message_metrics(logo_mock, template):
    logo_mock.metrics = dict(users=15, pageviews=25, clicks=3)
    message = create_message(logo_mock, template, date.today())
    html = message['html_content']

    assert '<b>15</b>' in html
    assert '<b>25</b>' in html
def test_create_message_job_slots_non_zero(logo_mock, template):
    logo_mock.job_slots = 43
    message = create_message(logo_mock, template, date(2020, 6, 23))
    html = message['html_content']

    assert 'paušál' in html
    assert 'současně inzerátů' in html
    assert '<b>43</b>' in html
def test_create_message_start_end(logo_mock, template):
    logo_mock.starts_at = date(2020, 6, 1)
    logo_mock.expires_at = date(2020, 7, 1)
    message = create_message(logo_mock, template, date(2020, 6, 23))
    html = message['html_content']

    assert '22&nbsp;dní' in html
    assert 'logo zobrazeno od&nbsp;1.6.2020' in html
    assert '8&nbsp;dní' in html
    assert 'sponzorství vyprší 1.7.2020' in html
def test_create_message_subject(logo_mock, template, expires_at, expected):
    logo_mock.expires_at = expires_at
    message = create_message(logo_mock, template, date(2020, 6, 20))

    assert message['subject'] == expected
def test_create_message_expires_not_soon(logo_mock, template):
    logo_mock.expires_at = date(2020, 7, 1)
    message = create_message(logo_mock, template, date(2020, 4, 20))
    html = message['html_content']

    assert 'Prodlužte' not in html