<commit_before>try:
    from unittest import mock
except ImportError:
    import mock

import pytest

from django.template.loader import render_to_string

from .factories import TimelineLogFactory


@pytest.mark.django_db
def test_render_message():
    log = TimelineLogFactory.create(extra_data={'foo': 'bar'})
    with mock.patch.object(log, 'get_message') as mock_get_message:
        render_to_string('test_render_message', {'log': log})
    mock_get_message.assert_called_once_with(template=None, extra_context='yes')<commit_msg>Skip test if not on PostgreSQL<commit_after>try:
    from unittest import mock
except ImportError:
    import mock

from django.conf import settings
from django.template.loader import render_to_string

import pytest

from .factories import TimelineLogFactory


@pytest.mark.skipif(
    settings.DATABASES['default']['ENGINE'] != 'django.db.backends.postgresql',
    reason='Requires PostgreSQL'
)
@pytest.mark.django_db
def test_render_message():
    log = TimelineLogFactory.create(extra_data={'foo': 'bar'})
    with mock.patch.object(log, 'get_message') as mock_get_message:
        render_to_string('test_render_message', {'log': log})
    mock_get_message.assert_called_once_with(template=None, extra_context='yes')
{'fraction_non_alphanumeric': 0.10366826156299841, 'fraction_numerical': 0.0, 'mean_word_length': 5.747311827956989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2944136', 'n_tokens_mistral': 395, 'n_tokens_neox': 398, 'n_words': 83}