예제 #1
0
 def test_non_unique_slug_if_different_sport(self):
     sport = SportFactory.create(name='Basketball')
     sport2 = SportFactory.create(name='Football')
     term = TermFactory.create(text='Rebound', sport=sport, user=self.user)
     term2 = TermFactory.create(text='Rebound',
                                sport=sport2,
                                user=self.user)
     self.assertEqual(term.slug, term2.slug)
예제 #2
0
    def setUpTestData(cls):
        # Create a sport, a term belonging to that sport & 10 definitions for that term
        sport = SportFactory.create(name='Sport')
        cls.term = TermFactory.create(sport=sport, text='Term for sport')

        cls.user = UserFactory.create(username='******')
        DefinitionFactory.create_batch(10, term=cls.term, user=cls.user)
예제 #3
0
 def setUpTestData(cls):
     u = UserFactory.create()
     su = UserFactory.create(is_staff=True)
     s = SportFactory.create()
     t = TermFactory.create(user=u, sport=s)
     SuggestedTermFactory.create(user=u, sport=s)
     CategoryFactory.create(sport=s)
     d = DefinitionFactory.create(user=u, term=t)
     VoteFactory.create(user=u, definition=d)
    def test_valid_internal_link_different_sport_no_label(self):
        different_sport = SportFactory.create(name='Different sport')
        term = TermFactory.create(sport=different_sport, text='Text')

        result = custom_urlize(f'[[{term.slug}]]', different_sport)
        self.assertEqual(
            result,
            f'<a href="{term.get_absolute_url()}" class="term-link-in-definition">{term.text.lower()}</a>'
        )
예제 #5
0
    def test_paginator_only_holds_terms_from_sport(self):
        another_sport = SportFactory.create(name='Another Sport')
        TermFactory.create(sport=another_sport, text='Term in another sport')

        response = self.client.get(
            reverse('sport_index', kwargs={'sport_slug': self.sport.slug}))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['paginator'].count, 100)

        # verify other term exists (total num of terms should = 101)
        terms = Term.objects.all()
        self.assertEqual(terms.count(), 101)
예제 #6
0
    def setUpTestData(cls):
        # Create 100 Terms in a single belonging to a single sport
        num_terms = 100
        cls.sport = SportFactory.create()

        TermFactory.create_batch(num_terms, sport=cls.sport)
예제 #7
0
 def test_unique_slug_if_same_sport(self):
     sport = SportFactory.create(name='Basketball')
     term = TermFactory.create(text='Rebound', sport=sport, user=self.user)
     term2 = TermFactory.create(text='rebound', sport=sport, user=self.user)
     self.assertNotEqual(term.slug, term2.slug)
예제 #8
0
 def test_get_absolute_url(self):
     sport = SportFactory.create(name='Football')
     term = TermFactory.create(text='False 9', sport=sport, user=self.user)
     self.assertEquals(term.get_absolute_url(), '/term/football/false-9')
예제 #9
0
 def test_unique_slug(self):
     sport = SportFactory.create(name='Football')
     sport2 = SportFactory.create(name='football')
     self.assertNotEqual(sport.slug, sport2.slug)
예제 #10
0
 def test_slug(self):
     sport = SportFactory.create(name='American Football')
     self.assertEqual(sport.slug, 'american-football')
예제 #11
0
 def test_get_absolute_url(self):
     sport = SportFactory.create(name='Football')
     self.assertEquals(sport.get_absolute_url(), '/terms/football/')
예제 #12
0
 def test_str_method(self):
     sport = SportFactory.create()
     self.assertEqual(str(sport), sport.name)
예제 #13
0
 def setUpTestData(cls):
     cls.user = UserFactory.create()
     cls.sport = SportFactory.create()
     cls.term = TermFactory.create()
     cls.definition = DefinitionFactory.create()
     cls.vote = VoteFactory.create()
예제 #14
0
 def setUpTestData(cls):
     SportFactory.create_batch(50)
     SportFactory.create(active=False)