示例#1
0
def test_site_settings_form(site_settings):
    data = {'header_text': 'mirumee', 'description': 'mirumee.com'}
    form = SiteSettingsForm(data, instance=site_settings)
    assert form.is_valid()

    site = form.save()
    assert site.header_text == 'mirumee'
    assert smart_text(site) == 'mirumee.com'

    form = SiteSettingsForm({})
    assert form.is_valid()
示例#2
0
def test_site_settings_default_sender_name_cannot_have_newlines(
    site_settings_form_data, sender_name, sender_address, expected_errors
):
    data = site_settings_form_data
    data.update(
        {
            "default_mail_sender_name": sender_name,
            "default_mail_sender_address": sender_address,
        }
    )
    form = SiteSettingsForm(data)
    assert not form.is_valid()
    assert form.errors == expected_errors
示例#3
0
def test_site_settings_form(site_settings):
    data = {
        "header_text": "mirumee",
        "description": "mirumee.com",
        "default_weight_unit": "lb",
    }
    form = SiteSettingsForm(data, instance=site_settings)
    assert form.is_valid()

    site = form.save()
    assert site.header_text == "mirumee"
    assert smart_text(site) == "mirumee.com"
    assert site.default_weight_unit == "lb"

    form = SiteSettingsForm({"default_weight_unit": "lb"})
    assert form.is_valid()
示例#4
0
def test_site_settings_form(site_settings):
    data = {'header_text': 'mirumee', 'description': 'mirumee.com'}
    form = SiteSettingsForm(data, instance=site_settings)
    assert form.is_valid()

    site = form.save()
    assert site.header_text == 'mirumee'
    assert smart_text(site) == 'mirumee.com'

    form = SiteSettingsForm({})
    assert form.is_valid()
示例#5
0
def test_site_settings_form(site_settings, site_settings_form_data):
    data = site_settings_form_data
    form = SiteSettingsForm(data, instance=site_settings)
    assert form.is_valid()

    site = form.save()
    assert site.header_text == "mirumee"
    assert smart_text(site) == "mirumee.com"
    assert site.default_weight_unit == "lb"

    form = SiteSettingsForm({"default_weight_unit": "lb"})
    assert form.is_valid()