<commit_before>#!/usr/bin/env python
"""
Test cases for launch_control.sample module
"""

import launch_control.sample
from launch_control.sample import QualitativeSample
from launch_control.tests.factory import Factory


import random
from unittest import TestCase

# Hack, see DocTestAwareTestLoader for insight
__doctest_module__ = launch_control.sample


class QualitativeSampleClassProperties(TestCase):
    """"Check for properties of QualitativeSample class"""
    def test_TEST_RESULT_PASS_is_pass(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_PASS, 'pass')

    def test_TEST_RESULT_FAIL_is_fail(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_FAIL, 'fail')

    def test_TEST_RESULT_SKIP_is_skip(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_SKIP, 'skip')

    def test_TEST_RESULT_CRASH_is_crash(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_CRASH, 'crash')


class QualitativeSampleConstruction(TestCase):
    """ Check construction behavior for QualitativeSample """

    def setUp(self):
        super(QualitativeSampleConstruction, self).setUp()
        self.factory = Factory()

    def test_constructor_requires_test_result(self):
        """ At least one argument is required: test_result """
        self.assertRaises(TypeError, QualitativeSample)

    def test_constructor_sets_test_result(self):
        """ Argument test_result is stored correctly for both supported
        values. """
        sample1 = self.factory.make_sample(test_result='fail')
        self.assertEqual(sample1.test_result, 'fail')
        sample2 = self.factory.make_sample(test_result='pass')
        self.assertEqual(sample2.test_result, 'pass')

    def test_constructor_defaults_test_id_to_None(self):
        """ Argument test_id defaults to None """
        sample = self.factory.make_sample()
        self.assertEqual(sample.test_id, None)

    def test_constructor_sets_test_id(self):
        """ Argument test_id is stored correctly """
        sample = self.factory.make_sample(test_id='test_id')
        self.assertEqual(sample.test_id, 'test_id')

    def test_constructor_defaults_message_to_None(self):
        """ Argument message defaults to None """
        sample = self.factory.make_sample()
        self.assertEqual(sample.message, None)
    def test_constructor_sets_bytestring_message(self):
        """ Argument message is stored correctly (for byte strings) """
        sample = self.factory.make_sample(message='foobar')<commit_msg>Add tests for skip/crash test_result<commit_after>#!/usr/bin/env python
"""
Test cases for launch_control.sample module
"""

import launch_control.sample
from launch_control.sample import QualitativeSample
from launch_control.tests.factory import Factory


import random
from unittest import TestCase

# Hack, see DocTestAwareTestLoader for insight
__doctest_module__ = launch_control.sample


class QualitativeSampleClassProperties(TestCase):
    """"Check for properties of QualitativeSample class"""
    def test_TEST_RESULT_PASS_is_pass(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_PASS, 'pass')

    def test_TEST_RESULT_FAIL_is_fail(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_FAIL, 'fail')

    def test_TEST_RESULT_SKIP_is_skip(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_SKIP, 'skip')

    def test_TEST_RESULT_CRASH_is_crash(self):
        self.assertEqual(QualitativeSample.TEST_RESULT_CRASH, 'crash')


class QualitativeSampleConstruction(TestCase):
    """ Check construction behavior for QualitativeSample """

    def setUp(self):
        super(QualitativeSampleConstruction, self).setUp()
        self.factory = Factory()

    def test_constructor_requires_test_result(self):
        """ At least one argument is required: test_result """
        self.assertRaises(TypeError, QualitativeSample)

    def test_constructor_sets_test_result(self):
        """ Argument test_result is stored correctly for both supported
        values. """
        sample1 = self.factory.make_sample(test_result='fail')
        self.assertEqual(sample1.test_result, 'fail')
        sample2 = self.factory.make_sample(test_result='pass')
        self.assertEqual(sample2.test_result, 'pass')
        sample2 = self.factory.make_sample(test_result='skip')
        self.assertEqual(sample2.test_result, 'skip')
        sample2 = self.factory.make_sample(test_result='crash')
        self.assertEqual(sample2.test_result, 'crash')

    def test_constructor_defaults_test_id_to_None(self):
        """ Argument test_id defaults to None """
        sample = self.factory.make_sample()
        self.assertEqual(sample.test_id, None)

    def test_constructor_sets_test_id(self):
        """ Argument test_id is stored correctly """
        sample = self.factory.make_sample(test_id='test_id')
        self.assertEqual(sample.test_id, 'test_id')

    def test_constructor_defaults_message_to_None(self):
        """ Argument message defaults to None """
        sample = self.factory.make_sample()
        self.assertEqual(sample.message, None)
    def test_constructor_sets_bytestring_message(self):
        """ Argument message is stored correctly (for byte strings) """
        sample = self.factory.make_sample(message='foobar')
{'fraction_non_alphanumeric': 0.09286930206166068, 'fraction_numerical': 0.0022697181766597315, 'mean_word_length': 4.225296442687747, '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': '4097520', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1457, 'n_words': 295}