<commit_before>from unittest.mock import Mock
from app.master.atom import Atom
from app.master.job_config import JobConfig

from app.master.subjob import Subjob
from app.project_type.project_type import ProjectType
from test.framework.base_unit_test_case import BaseUnitTestCase


class TestSubjob(BaseUnitTestCase):

    def test_api_representation_matches_expected(self):
        job_config_command = 'fake command'
        subjob = Subjob(
            build_id=12,
            subjob_id=34,
            project_type=Mock(spec_set=ProjectType),
            job_config=Mock(spec=JobConfig, command=job_config_command),
            atoms=[
                Atom('BREAKFAST', 'pancakes', expected_time=23.4, actual_time=56.7),
                Atom('BREAKFAST', 'cereal', expected_time=89.0, actual_time=24.6),
            ],
        )

        actual_api_repr = subjob.api_representation()

        expected_api_repr = {
            'id': 34,
            'command': job_config_command,
            'atoms': [
                {'id': 0, 'atom': 'export BREAKFAST="pancakes";', 'expected_time': 23.4, 'actual_time': 56.7},
                {'id': 1, 'atom': 'export BREAKFAST="cereal";', 'expected_time': 89.0, 'actual_time': 24.6},
            ]
        }
        self.assertEqual(actual_api_repr, expected_api_repr, 'Actual api representation should match expected.')<commit_msg>Make test_subjob cross platform<commit_after>from unittest.mock import Mock
from app.master.atom import Atom
from app.master.job_config import JobConfig

from app.master.subjob import Subjob
from app.project_type.project_type import ProjectType
from app.util.process_utils import get_environment_variable_setter_command
from test.framework.base_unit_test_case import BaseUnitTestCase


class TestSubjob(BaseUnitTestCase):

    def test_api_representation_matches_expected(self):
        job_config_command = 'fake command'
        subjob = Subjob(
            build_id=12,
            subjob_id=34,
            project_type=Mock(spec_set=ProjectType),
            job_config=Mock(spec=JobConfig, command=job_config_command),
            atoms=[
                Atom('BREAKFAST', 'pancakes', expected_time=23.4, actual_time=56.7),
                Atom('BREAKFAST', 'cereal', expected_time=89.0, actual_time=24.6),
            ],
        )

        actual_api_repr = subjob.api_representation()

        expected_api_repr = {
            'id': 34,
            'command': job_config_command,
            'atoms': [
                {
                    'id': 0,
                    'atom': get_environment_variable_setter_command('BREAKFAST', 'pancakes'),
                    'expected_time': 23.4,
                    'actual_time': 56.7,
                },
                {
                    'id': 1,
                    'atom': get_environment_variable_setter_command('BREAKFAST', 'cereal'),
                    'expected_time': 89.0,
                    'actual_time': 24.6,
                },
            ]
        }
        self.assertEqual(actual_api_repr, expected_api_repr, 'Actual api representation should match expected.')
{'fraction_non_alphanumeric': 0.10099710517851399, 'fraction_numerical': 0.020585397233837247, 'mean_word_length': 2.3440860215053765, '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': '4309842', 'n_tokens_mistral': 979, 'n_tokens_neox': 901, 'n_words': 168}