# -*- coding: utf-8 -*-
"""Tests for the :mod:`biblary.templatetags` module."""
import pytest

from biblary.templatetags.authors import main_author_class


@pytest.mark.parametrize('patterns', (('<NAME>',), (r'.*Einstein',)))
def test_authors_main_author_class(get_bibliography, patterns):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag."""
    with get_bibliography(bibliography_main_author_patterns=patterns):
        assert main_author_class('<NAME>') is not None
        assert main_author_class('<NAME>') is None


@pytest.mark.parametrize('patterns', (('<NAME>'), (r'.*Einstein')))
def test_authors_main_author_class_raises(get_bibliography, patterns):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag when it should raise."""
    with get_bibliography(bibliography_main_author_patterns=patterns):
        with pytest.raises(TypeError):
            main_author_class('<NAME>')


def test_authors_main_author_class_custom_class(get_bibliography):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag with custom class."""
    patterns = ('<NAME>',)
    custom_class = 'custom-class'

    with get_bibliography(bibliography_main_author_patterns=patterns, bibliography_main_author_class=custom_class):
        assert main_author_class('<NAME>') == custom_class

# -*- coding: utf-8 -*-
"""Tests for the :mod:`biblary.templatetags` module."""
import pytest

from biblary.templatetags.authors import main_author_class


@pytest.mark.parametrize('patterns', (('<NAME>',), (r'.*Einstein',)))
def test_authors_main_author_class(get_bibliography, patterns):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag."""
    with get_bibliography(bibliography_main_author_patterns=patterns):
        assert main_author_class('<NAME>') is not None
        assert main_author_class('<NAME>') is None


@pytest.mark.parametrize('patterns', (('<NAME>'), (r'.*Einstein')))
def test_authors_main_author_class_raises(get_bibliography, patterns):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag when it should raise."""
    with get_bibliography(bibliography_main_author_patterns=patterns):
        with pytest.raises(TypeError):
            main_author_class('<NAME>')


def test_authors_main_author_class_custom_class(get_bibliography):
    """Test the :class:`biblary.templatetags.authors:main_author_class` template tag with custom class."""
    patterns = ('<NAME>',)
    custom_class = 'custom-class'

    with get_bibliography(bibliography_main_author_patterns=patterns, bibliography_main_author_class=custom_class):
        assert main_author_class('<NAME>') == custom_class

# -*- coding: utf-8 -*- Tests for the :mod:`biblary.templatetags` module. Test the :class:`biblary.templatetags.authors:main_author_class` template tag. Test the :class:`biblary.templatetags.authors:main_author_class` template tag when it should raise. Test the :class:`biblary.templatetags.authors:main_author_class` template tag with custom class.