<commit_before>from django.test import TestCase
from django.contrib.auth.models import User
from dwitter.models import Dweet
from dwitter.models import Comment
from django.utils import timezone
from datetime import timedelta


class DweetTestCase(TestCase):
    def setUp(self):
        user1 = User.objects.create(username="user1", password="")
        user2 = User.objects.create(username="user2", password="")

        now = timezone.now()

        dweet1 = Dweet.objects.create(id=1,
                                      code="dweet1 code",
                                      posted=now - timedelta(minutes=1),
                                      _author=user1)

        dweet2 = Dweet.objects.create(id=2,
                                      code="dweet2 code",
                                      posted=now,
                                      reply_to=dweet1,
                                      _author=user2)

        comment1 = Comment.objects.create(id=1,
                                          text="comment1 text",
                                          posted=now - timedelta(minutes=1),
                                          reply_to=dweet2,
                                          _author=user1)

        comment1 = Comment.objects.create(id=2,
                                          text="comment2 text",
                                          posted=now,
                                          reply_to=dweet1,
                                          _author=user2)

    def test_comment_renders_to_string_correctly(self):
        self.assertEqual(Comment.objects.get(id=1).__unicode__(),
                         "c/1 (user1) to d/2 (user2)")
        self.assertEqual(Comment.objects.get(id=2).__unicode__(),
                         "c/2 (user2) to d/1 (user1)")

    def test_comment_reply_to_do_nothing_on_soft_delete(self):
        Dweet.objects.get(id=2).delete()
        self.assertTrue(Comment.objects.get(id=1).reply_to.deleted)
        self.assertEqual(Comment.objects.get(id=2).reply_to,<commit_msg>linting<commit_after>from django.test import TestCase
from django.contrib.auth.models import User
from dwitter.models import Dweet
from dwitter.models import Comment
from django.utils import timezone
from datetime import timedelta


class DweetTestCase(TestCase):
    def setUp(self):
        user1 = User.objects.create(username="user1", password="")
        user2 = User.objects.create(username="user2", password="")

        now = timezone.now()

        dweet1 = Dweet.objects.create(id=1,
                                      code="dweet1 code",
                                      posted=now - timedelta(minutes=1),
                                      _author=user1)

        dweet2 = Dweet.objects.create(id=2,
                                      code="dweet2 code",
                                      posted=now,
                                      reply_to=dweet1,
                                      _author=user2)

        Comment.objects.create(id=1,
                               text="comment1 text",
                               posted=now - timedelta(minutes=1),
                               reply_to=dweet2,
                               _author=user1)

        Comment.objects.create(id=2,
                               text="comment2 text",
                               posted=now,
                               reply_to=dweet1,
                               _author=user2)

    def test_comment_renders_to_string_correctly(self):
        self.assertEqual(Comment.objects.get(id=1).__unicode__(),
                         "c/1 (user1) to d/2 (user2)")
        self.assertEqual(Comment.objects.get(id=2).__unicode__(),
                         "c/2 (user2) to d/1 (user1)")

    def test_comment_reply_to_do_nothing_on_soft_delete(self):
        Dweet.objects.get(id=2).delete()
        self.assertTrue(Comment.objects.get(id=1).reply_to.deleted)
        self.assertEqual(Comment.objects.get(id=2).reply_to,
{'fraction_non_alphanumeric': 0.09262948207171315, 'fraction_numerical': 0.018426294820717132, 'mean_word_length': 1.331398723157284, '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': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1349128', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1005, 'n_words': 165}