def test_image_fallback():
    company = CompanyFactory.build()

    assert company.image
    assert company.image_url_or_default() == company.image.url

    company = CompanyFactory.build(image=None)

    assert not company.image
    assert company.image_url_or_default() == '/static/mysign_app/image-fallback.png'
def test_logo_fallback():
    company = CompanyFactory.build()

    assert company.logo
    assert company.logo_url_or_default() == company.logo.url

    company = CompanyFactory.build(logo=None)

    assert not company.logo
    assert company.logo_url_or_default() == '/static/mysign_app/logo-fallback.png'
def test_website():
    company = CompanyFactory.build(website='no-site')

    with pytest.raises(ValidationError):
        company.full_clean()

    company = CompanyFactory.build(website='http://example.com')
    company.full_clean()

    company = CompanyFactory.build(website='example.com')
    company.full_clean()
Exemple #4
0
def test_company_add(client):
    is_admin_route(client, reverse('admin_company_add'))

    client_login(client, is_admin=True)
    company_payload = payload_from_form(
        CompanyForm(instance=CompanyFactory.build()), prefix='company')
    user_payload = payload_from_form(
        AddCompanyUserForm(instance=UserFactory.build()), prefix='user')
    payload = {**company_payload, **user_payload}

    response = client.post(reverse('admin_company_add'), payload)

    assert response.status_code == 302
    assert response.url == reverse('admin_companies')
    assert Company.objects.count() == 1
    assert len(mail.outbox) == 1
    assert mail.outbox[0].subject == 'Welkom'
    assert User.objects.count(
    ) == 2  # One is logged in user, other created user
def test_str():
    company = CompanyFactory.build(name="test")

    assert str(company) == "test"
def test_phone_number():
    company = CompanyFactory.build(phone_number='belmij!')

    with pytest.raises(ValidationError):
        company.full_clean()