<commit_before># This file is part of the GOsa framework.
#
#  http://gosa-project.org
#
# Copyright:
#  (C) 2016 GONICUS GmbH, Germany, http://www.gonicus.de
#
# See the LICENSE file in the project's top-level directory for details.

import unittest
from gosa.backend.objects.comparator.basic import Equals, Greater, Smaller

class BasicComparatorTests(unittest.TestCase):

    def test_equals(self):
        comp = Equals()
        (result, errors) = comp.process(None, None, ["test","test"], "test")
        assert result == True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["test", "test1"], "test")
        assert result == False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test2", "test1"], "test")
        assert result == False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test", "test"], "Test", case_ignore=True)
        assert result == True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["test", "test1"], "Test", case_ignore=True)
        assert result == False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test2", "test1"], "Test", case_ignore=True)
        assert result == False
        assert len(errors) == 1

    def test_greater(self):
        comp = Greater()

        # test string numbers
        (result, errors) = comp.process(None, None, ["5", "6"], "3")
        assert result == True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["5", "1"], "3")
        assert result == False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["1", "2"], "3")
        assert result == False
        assert len(errors) == 1

    def test_smaller(self):
        comp = Smaller()

        (result, errors) = comp.process(None, None, ["5", "6"], "13")
        assert result == True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["5", "1"], "3")
        assert result == False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["5", "6"], "3")
        assert result == False
        assert len(errors) == 1<commit_msg>test filters with int values again<commit_after># This file is part of the GOsa framework.
#
#  http://gosa-project.org
#
# Copyright:
#  (C) 2016 GONICUS GmbH, Germany, http://www.gonicus.de
#
# See the LICENSE file in the project's top-level directory for details.

import unittest
from gosa.backend.objects.comparator.basic import Equals, Greater, Smaller


class BasicComparatorTests(unittest.TestCase):

    def test_equals(self):
        comp = Equals()
        (result, errors) = comp.process(None, None, ["test","test"], "test")
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["test", "test1"], "test")
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test2", "test1"], "test")
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test", "test"], "Test", case_ignore=True)
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["test", "test1"], "Test", case_ignore=True)
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["test2", "test1"], "Test", case_ignore=True)
        assert result is False
        assert len(errors) == 1

    def test_greater(self):
        comp = Greater()
        (result, errors) = comp.process(None, None, [5, 6], 3)
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, [5, 1], 3)
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, [1, 2], 3)
        assert result is False
        assert len(errors) == 1

        # test string numbers
        (result, errors) = comp.process(None, None, ["5", "6"], "3")
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["5", "1"], "3")
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["1", "2"], "3")
        assert result is False
        assert len(errors) == 1

    def test_smaller(self):
        comp = Smaller()
        (result, errors) = comp.process(None, None, [5, 6], 13)
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, [5, 1], 3)
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, [5, 6], 3)
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["5", "6"], "13")
        assert result is True
        assert len(errors) == 0

        (result, errors) = comp.process(None, None, ["5", "1"], "3")
        assert result is False
        assert len(errors) == 1

        (result, errors) = comp.process(None, None, ["5", "6"], "3")
        assert result is False
        assert len(errors) == 1
{'fraction_non_alphanumeric': 0.15128253136116832, 'fraction_numerical': 0.0200337015540161, 'mean_word_length': 2.498362802881467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4261761', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1589, 'n_words': 522}