<commit_before>from django.test import TestCase
from django.urls import reverse

from .models import Topic


class IndexViewTest(TestCase):

    def test_index_with_no_topics(self):
        pass
        # response = self.client.get(reverse('topics:index'))
        # self.assertEqual(response.status_code, 200)

    def test_index_with_one_topic(self):
        Topic.objects.create(name='Binary Numbers')
        response = self.client.get(reverse('topics:index'))
        print(response)
        self.assertQuerysetEqual(
            response.context['all_topics'],
            ['<Topic: Binary Numbers>']
        )
<commit_msg>Added basic setup and teardown. Bug still at large.<commit_after>from django.test import TestCase
from django.urls import reverse
from django.contrib.auth.models import User
from django.test.client import Client

from .models import Topic




class IndexViewTest(TestCase):

    def setUp(self):
        self.client = Client()
        self.username = 'test'
        self.email = '<EMAIL>'
        self.password = '<PASSWORD>'        
        self.test_user = User.objects.create_user(self.username, self.email, self.password)
        login = self.client.login(username=self.username, password=self.password)
        self.assertEqual(login, True)

    def tearDown(self):
        self.test_user.delete()

    def test_index_with_no_topics(self):
        pass
        # url = reverse('topics:index')
        # response = self.client.get(url)
        # self.assertEqual(response.status_code, 200)

    def test_index_with_one_topic(self):
        new_topic = Topic(
            slug = 'binary-numbers',
            name='Binary Numbers',
            content = 'content',
            other_resources = 'content',
            icon = 'icon'
        )
        new_topic.save()
        print(new_topic)
        print(new_topic.id)
        print(Topic.objects.all())
        url = reverse('topics:index')
        response = self.client.get(url)
        print(response)
        self.assertEqual(200, response.status_code)
        self.assertQuerysetEqual(
            response.context['all_topics'],
            ['<Topic: Binary Numbers>']
        )

{'fraction_non_alphanumeric': 0.1078838174273859, 'fraction_numerical': 0.004149377593360996, 'mean_word_length': 2.5284552845528454, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2615502', 'n_tokens_mistral': 636, 'n_tokens_neox': 613, 'n_words': 124}