<commit_before>import pytest
from nose.tools import eq_
from django_nose.tools import assert_queryset_equal

from shmitter.likes import services
from shmitter.tweets.models import Tweet
from .. import factories as f

pytestmark = pytest.mark.django_db


def test_add_and_remove_like():
    user_1 = f.UserFactory()
    user_2 = f.UserFactory()
    tweet_1 = f.TweetFactory()

    services.add_like(tweet_1, user_1)
    eq_(tweet_1.likes.count(), 1)

    services.add_like(tweet_1, user_1)
    eq_(tweet_1.likes.count(), 1)

    services.add_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 2)

    services.remove_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 1)

    services.remove_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 1)


def test_get_liked():
    user_1 = f.UserFactory()
    tweet_1 = f.TweetFactory()
    tweet_2 = f.TweetFactory()
    f.TweetFactory()

    f.LikeTweetFactory(content_object=tweet_1, user=user_1)
    f.LikeTweetFactory(content_object=tweet_2, user=user_1)

    assert_queryset_equal(
        services.get_liked(Tweet, user_1),
        [repr(tweet_2), repr(tweet_1)]
    )


def test_get_fans():
    tweet_1 = f.TweetFactory.create()
    user_1 = f.UserFactory.create()
    user_2 = f.UserFactory.create()
    f.UserFactory.create()

    f.LikeTweetFactory.create(content_object=tweet_1, user=user_1)
    f.LikeTweetFactory.create(content_object=tweet_1, user=user_2)

    assert_queryset_equal(
        services.get_fans(tweet_1),
        [repr(user_1), repr(user_2)],
        ordered=False
    )
<commit_msg>Add additional assert to the test<commit_after>import pytest
from nose.tools import eq_
from django_nose.tools import assert_queryset_equal

from shmitter.likes import services
from shmitter.tweets.models import Tweet
from .. import factories as f

pytestmark = pytest.mark.django_db


def test_add_and_remove_like():
    user_1 = f.UserFactory()
    user_2 = f.UserFactory()
    tweet_1 = f.TweetFactory()

    services.add_like(tweet_1, user_1)
    eq_(tweet_1.likes.count(), 1)

    services.add_like(tweet_1, user_1)
    eq_(tweet_1.likes.count(), 1)

    services.add_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 2)

    services.remove_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 1)

    services.remove_like(tweet_1, user_2)
    eq_(tweet_1.likes.count(), 1)


def test_get_liked():
    user_1 = f.UserFactory()
    tweet_1 = f.TweetFactory()
    tweet_2 = f.TweetFactory()
    f.TweetFactory()

    f.LikeTweetFactory(content_object=tweet_1, user=user_1)
    f.LikeTweetFactory(content_object=tweet_2, user=user_1)

    assert_queryset_equal(
        services.get_liked(Tweet, user_1),
        [repr(tweet_2), repr(tweet_1)]
    )
    assert_queryset_equal(
        services.get_liked(Tweet, user_1.id),
        [repr(tweet_2), repr(tweet_1)]
    )


def test_get_fans():
    tweet_1 = f.TweetFactory.create()
    user_1 = f.UserFactory.create()
    user_2 = f.UserFactory.create()
    f.UserFactory.create()

    f.LikeTweetFactory.create(content_object=tweet_1, user=user_1)
    f.LikeTweetFactory.create(content_object=tweet_1, user=user_2)

    assert_queryset_equal(
        services.get_fans(tweet_1),
        [repr(user_1), repr(user_2)],
        ordered=False
    )

{'fraction_non_alphanumeric': 0.11380368098159509, 'fraction_numerical': 0.027300613496932514, 'mean_word_length': 3.781524926686217, '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': '3087424', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1252, 'n_words': 188}