<commit_before># -*- coding: utf-8 -*-
"""
Models tests.

"""
from django import test
from django.contrib.auth.models import User
from jobsubd.ttypes import State
from jobsub.models import Submission

from cosmos.models import JobRun


class JobRunTestCase(test.TestCase):

    def setUp(self):
        self.job = JobRun(id=15, name='wordcount',
                          description="hadoop's hello world",
                          user=User(id=1, username='jsmith'),
                          dataset_path='/user/jsmith/datasets/text.txt',
                          jar_path='/user/jsmith/jars/wordcount.jar',
                          submission=Submission(id=23))

    def test_hadoop_args(self):
        self.assertEquals(self.job.hadoop_args('job.jar'),
                          ['jar', 'job.jar', '/user/jsmith/datasets/text.txt',
                           '/user/jsmith/tmp/job_15/',
                           'mongodb://localhost/db_1.job_15'])

    def assert_link_in_states(self, link, states):
        for state in states:
            self.job.submission.last_seen_state = state
            links = self.job.action_links()
            self.assertTrue(link in links, msg=('Should have "%s" link in "%s"' +
                            ' state (actual links: %s)') %
                            (link['name'], self.job.status(), links))


    def test_action_links(self):
        self.assert_link_in_states({'name': 'Results',
                                    'class': 'results',
                                    'target': None,
                                    'href': '/cosmos/job/15/results/'},
                                   [State.SUCCESS])

        self.assert_link_in_states({'name': 'Detailed status',
                                    'class': 'status',<commit_msg>Fix model test<commit_after># -*- coding: utf-8 -*-
"""
Models tests.

"""
from django import test
from django.contrib.auth.models import User
from jobsubd.ttypes import State
from jobsub.models import Submission

from cosmos.models import JobRun


class JobRunTestCase(test.TestCase):

    def setUp(self):
        self.job = JobRun(id=15, name='wordcount',
                          description="hadoop's hello world",
                          user=User(id=1, username='jsmith'),
                          dataset_path='/user/jsmith/datasets/text.txt',
                          jar_path='/user/jsmith/jars/wordcount.jar',
                          submission=Submission(id=23))

    def test_hadoop_args(self):
        self.assertEquals(self.job.hadoop_args('job.jar'),
                          ['jar', 'job.jar', '/user/jsmith/datasets/text.txt',
                           '/user/jsmith/tmp/job_15/',
                           'mongodb://localhost/db_1.job_15'])

    def assert_link_in_states(self, link, states):
        for state in states:
            self.job.submission.last_seen_state = state
            links = self.job.action_links()
            self.assertTrue(link in links, msg=('Should have "%s" link in "%s"' +
                            ' state (actual links: %s)') %
                            (link['name'], self.job.state(), links))


    def test_action_links(self):
        self.assert_link_in_states({'name': 'Results',
                                    'class': 'results',
                                    'target': None,
                                    'href': '/cosmos/job/15/results/'},
                                   [State.SUCCESS])

        self.assert_link_in_states({'name': 'Detailed status',
                                    'class': 'status',
{'fraction_non_alphanumeric': 0.12597114317425084, 'fraction_numerical': 0.007214206437291898, 'mean_word_length': 1.5441072688779112, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7392092', 'n_tokens_mistral': 1001, 'n_tokens_neox': 962, 'n_words': 185}