"""This module holds the tests managers of the ``likes`` app."""

from mtp.apps.likes.models import Like

from .tests_cases import BaseLikeTestCase


class LikeManagerTestCase(BaseLikeTestCase):
    """Test case that tests the ``Like`` manager."""

    def test_queryset_filter_on_author(self):
        """Test the filter on author."""

        queryset = Like.objects.for_author(self.trainee1)
        self.assertEqual(queryset.count(), 2)

        queryset = Like.objects.for_author(self.trainee2)
        self.assertEqual(queryset.count(), 1)

        queryset = Like.objects.for_author(self.trainee3)
        self.assertEqual(queryset.count(), 2)

    def test_queryset_filter_on_weight(self):
        """Test the filter on weight."""

        queryset = Like.objects.for_weight(-1)
        self.assertEqual(queryset.count(), 1)

        queryset = Like.objects.for_weight(1)
        self.assertEqual(queryset.count(), 1)

        queryset = Like.objects.for_weight(2)
        self.assertEqual(queryset.count(), 1)

        queryset = Like.objects.for_weight(5)
        self.assertEqual(queryset.count(), 2)

    def test_queryset_filter_on_positive_like(self):
        """Test the filter on positive like."""

        queryset = Like.objects.for_positive_like()
        self.assertEqual(queryset.count(), 4)

    def test_queryset_filter_on_negative_like(self):
        """Test the filter on negative like."""

        queryset = Like.objects.for_negative_like()
        self.assertEqual(queryset.count(), 1)
