<commit_before># Python
import pytest
import mock
import json

# AWX
from awx.api.serializers import (
    JobSerializer,
    JobOptionsSerializer,
)

from awx.main.models import (
    Label,
    Job,
)


def mock_JT_resource_data():
    return ({}, [])


@pytest.fixture
def job_template(mocker):
    mock_jt = mocker.MagicMock(pk=5)
    mock_jt.resource_validation_data = mock_JT_resource_data
    return mock_jt


@pytest.fixture
def project_update(mocker):
    mock_pu = mocker.MagicMock(pk=1)
    return mock_pu


@pytest.fixture
def job(mocker, job_template, project_update):
    return mocker.MagicMock(pk=5, job_template=job_template, project_update=project_update)


@pytest.fixture
def labels(mocker):
    return [Label(id=x, name='label-%d' % x) for x in xrange(0, 25)]


@pytest.fixture
def jobs(mocker):
    return [Job(id=x, name='job-%d' % x) for x in xrange(0, 25)]


@mock.patch('awx.api.serializers.UnifiedJobTemplateSerializer.get_related', lambda x,y: {})
@mock.patch('awx.api.serializers.JobOptionsSerializer.get_related', lambda x,y: {})
class TestJobSerializerGetRelated():
    @pytest.mark.parametrize("related_resource_name", [
        'job_events',
        'job_plays',
        'job_tasks',
        'relaunch',
        'labels',
    ])
    def test_get_related(self, test_get_related, job, related_resource_name):
        test_get_related(JobSerializer, job, 'jobs', related_resource_name)
<commit_msg>Pytest fixture adjustment.<commit_after># Python
import pytest
import mock
import json

# AWX
from awx.api.serializers import (
    JobSerializer,
    JobOptionsSerializer,
)

from awx.main.models import (
    Label,
    Job,
)


def mock_JT_resource_data():
    return ({}, [])


@pytest.fixture
def job_template(mocker):
    mock_jt = mocker.MagicMock(pk=5)
    mock_jt.resource_validation_data = mock_JT_resource_data
    return mock_jt


@pytest.fixture
def project_update(mocker):
    mock_pu = mocker.MagicMock(pk=1)
    return mock_pu


@pytest.fixture
def job(mocker, job_template, project_update):
    return mocker.MagicMock(pk=5, job_template=job_template, project_update=project_update,
                            workflow_job_id=None)


@pytest.fixture
def labels(mocker):
    return [Label(id=x, name='label-%d' % x) for x in xrange(0, 25)]


@pytest.fixture
def jobs(mocker):
    return [Job(id=x, name='job-%d' % x) for x in xrange(0, 25)]


@mock.patch('awx.api.serializers.UnifiedJobTemplateSerializer.get_related', lambda x,y: {})
@mock.patch('awx.api.serializers.JobOptionsSerializer.get_related', lambda x,y: {})
class TestJobSerializerGetRelated():
    @pytest.mark.parametrize("related_resource_name", [
        'job_events',
        'job_plays',
        'job_tasks',
        'relaunch',
        'labels',
    ])
    def test_get_related(self, test_get_related, job, related_resource_name):
        test_get_related(JobSerializer, job, 'jobs', related_resource_name)

{'fraction_non_alphanumeric': 0.1209318259677972, 'fraction_numerical': 0.006166495375128468, 'mean_word_length': 4.186500888099467, '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': '1561897', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1026, 'n_words': 191}