<commit_before>from ddt import data, ddt

from django.core.exceptions import ValidationError
from rest_framework import test

from nodeconductor.core import validators
from nodeconductor.structure.models import Customer


class NameValidationTest(test.APITransactionTestCase):
    def test_name_should_have_at_least_one_non_whitespace_character(self):
        with self.assertRaises(ValidationError):
            customer = Customer(name='      ')
            customer.full_clean()


@ddt
class MinCronValueValidatorTest(test.APITransactionTestCase):

    @data('*/1 * * * *', '*/10 * * * *', '*/59 * * * *')
    def test_validator_raises_validation_error_if_given_schedule_value_is_less_than_1_hours(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        with self.assertRaises(ValidationError):
            validator(value)

    @data('hello world', '* * * * * *', '*/59')
    def test_validator_raises_validation_error_if_given_format_is_not_valid(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        with self.assertRaises(ValidationError):
            validator(value)

    @data('0 * * * *', '0 0 * * *', '0 0 0 * *', '0 0 * * 0', '0 0 1 * *', '0 0 1 1 *', '0 0 1 1 *')
    def test_validator_does_not_raise_error_if_schedule_is_bigger_than_1_hour(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        validator(value)<commit_msg>Rename unit test [WAL-557]<commit_after>from ddt import data, ddt

from django.core.exceptions import ValidationError
from rest_framework import test

from nodeconductor.core import validators
from nodeconductor.structure.models import Customer


class NameValidationTest(test.APITransactionTestCase):
    def test_name_should_have_at_least_one_non_whitespace_character(self):
        with self.assertRaises(ValidationError):
            customer = Customer(name='      ')
            customer.full_clean()


@ddt
class MinCronValueValidatorTest(test.APITransactionTestCase):

    @data('*/1 * * * *', '*/10 * * * *', '*/59 * * * *')
    def test_validator_raises_validation_error_if_given_schedule_value_is_less_than_1_hours(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        with self.assertRaises(ValidationError):
            validator(value)

    @data('hello world', '* * * * * *', '*/59')
    def test_validator_raises_validation_error_if_given_format_is_not_valid(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        with self.assertRaises(ValidationError):
            validator(value)

    @data('0 * * * *', '0 0 * * *', '0 0 0 * *', '0 0 * * 0', '0 0 1 * *', '0 0 1 1 *', '0 0 1 1 *')
    def test_validator_does_not_raise_error_if_schedule_is_greater_than_or_equal_1_hour(self, value):
        validator = validators.MinCronValueValidator(limit_value=1)
        validator(value)
{'fraction_non_alphanumeric': 0.11164548265200962, 'fraction_numerical': 0.023016145654414292, 'mean_word_length': 4.117750439367311, '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': '6709258', 'n_tokens_mistral': 989, 'n_tokens_neox': 924, 'n_words': 164}