Exemplo n.º 1
0
def test_search_required_empty_sector_term():
    form = forms.CompanySearchForm(data={'term': '', 'sectors': ''})

    assert form.is_valid() is False

    assert form.errors == {
        '__all__': [forms.CompanySearchForm.MESSAGE_MISSING_SECTOR_TERM]
    }
Exemplo n.º 2
0
def test_company_search_submitted_shows_filters():
    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(data={'term': 'things'}),
    }

    html = render_to_string(template_name, context)

    assert SEARCH_FILTERS_LABEL in html
Exemplo n.º 3
0
def test_company_search_unsubmitted_hides_filters():
    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(),
    }

    html = render_to_string(template_name, context)

    assert SEARCH_FILTERS_LABEL not in html
Exemplo n.º 4
0
def test_search_form():
    form = forms.CompanySearchForm(data={
        'term': '123',
        'sectors': ['AEROSPACE']
    })

    assert form.is_valid() is True
    assert form.cleaned_data['term'] == '123'
    assert form.cleaned_data['sectors'] == ['AEROSPACE']
Exemplo n.º 5
0
def test_company_search_shows_result_count(count, expected):

    paginator = Paginator(range(count), 10)
    pagination = paginator.page(1)

    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(data={'term': 'things'}),
        'pagination': pagination,
        'results': [default_context['company']] * count,
    }

    html = render_to_string(template_name, context)

    assert expected in html
Exemplo n.º 6
0
def test_search_required_fields():
    form = forms.CompanySearchForm()

    assert form.fields['sectors'].required is False
    assert form.fields['term'].required is False