Пример #1
0
 def setUp(self):
     self.translations = [
         {
             'pl': 'kobieta',
             'br': 'a mulher',
             'en': 'woman',
             'group': 'basics',
         },
         {
             'pl': 'dziewczyna',
             'br': 'a menina',
             'en': 'girl',
             'group': 'basics',
         },
         {
             'pl': 'mężczyzna',
             'br': 'o homem',
             'en': 'man',
             'group': 'basics2',
         },
         {
             'pl': 'chłopiec',
             'br': 'o menino',
             'en': 'boy',
             'group': 'basics2',
         },
     ]
     self.count_filter = CountFilter(1)
     self.big_count_filter = CountFilter(len(self.translations) + 1)
Пример #2
0
class CountFilterTests(unittest.TestCase):
    def setUp(self):
        self.translations = [
            {
                'pl': 'kobieta',
                'br': 'a mulher',
                'en': 'woman',
                'group': 'basics',
            },
            {
                'pl': 'dziewczyna',
                'br': 'a menina',
                'en': 'girl',
                'group': 'basics',
            },
            {
                'pl': 'mężczyzna',
                'br': 'o homem',
                'en': 'man',
                'group': 'basics2',
            },
            {
                'pl': 'chłopiec',
                'br': 'o menino',
                'en': 'boy',
                'group': 'basics2',
            },
        ]
        self.count_filter = CountFilter(1)
        self.big_count_filter = CountFilter(len(self.translations) + 1)

    def test_small_count(self):
        filtered = self.count_filter.filter(self.translations)
        self.assertEqual(len(filtered), 1)
        self.assertEqual(filtered, self.translations[-1:])

    def test_big_count(self):
        filtered = self.big_count_filter.filter(self.translations)
        self.assertEqual(len(filtered), len(self.translations))
        self.assertEqual(filtered, self.translations)