示例#1
0
 def setUp(self):
     self.split_date = date(2010, 6, 18)
     ops1 = Opinion.objects.no_cache().filter(created__lt=self.split_date)
     ops2 = Opinion.objects.no_cache().filter(created__gte=self.split_date)
     self.t1 = Term(term='Hello')
     self.t1.save()
     self.t2 = Term(term='World')
     self.t2.save()
     for o in ops1:
         o.terms.add(self.t1)
     for o in ops2:
         o.terms.add(self.t2)
示例#2
0
class TermTestCase(TestCase):
    fixtures = ['feedback/opinions']

    def setUp(self):
        self.split_date = date(2010, 6, 18)
        ops1 = Opinion.objects.no_cache().filter(
            created__lt=self.split_date)
        ops2 = Opinion.objects.no_cache().filter(
            created__gte=self.split_date)
        self.t1 = Term(term='Hello')
        self.t1.save()
        self.t2 = Term(term='World')
        self.t2.save()
        for o in ops1:
            o.terms.add(self.t1)
        for o in ops2:
            o.terms.add(self.t2)

    def tearDown(self):
        Term.objects.all().delete()

    def test_frequent_from_opinions(self):
        """Test frequent term listing based on opinions queryset."""
        ops = Opinion.objects.no_cache()
        ts = Term.objects.frequent(ops)
        assert ts.count() > 0

    def test_frequent_by_date(self):
        """Test frequent terms by date."""
        ts = Term.objects.frequent(date_end=self.split_date)
        eq_(ts[0].term, self.t1.term)

        ts = Term.objects.frequent(date_start=self.split_date)
        eq_(ts[0].term, self.t2.term)

    def test_frequent_stats(self):
        """Test frequent terms weights."""
        ts = Term.objects.frequent()
        freq = frequent_terms(qs=ts)
        eq_(len(freq), 2)

    def test_unicode(self):
        """Term's unicode representation."""
        t = Term(term='Hello')
        eq_(unicode(t), u'Hello')

    @patch.object(settings._wrapped, 'DISABLE_TERMS', False)
    def test_term_extraction(self):
        """Make sure we create our terms."""
        settings.DISABLE_TERMS = False
        op = Opinion.objects.create(product=1, description='This is a test')
        terms = [term.term for term in op.terms.all()]
        eq_(terms, ['test'])
示例#3
0
class TermTestCase(TestCase):
    fixtures = ['feedback/opinions']

    def setUp(self):
        self.split_date = date(2010, 6, 18)
        ops1 = Opinion.objects.no_cache().filter(created__lt=self.split_date)
        ops2 = Opinion.objects.no_cache().filter(created__gte=self.split_date)
        self.t1 = Term(term='Hello')
        self.t1.save()
        self.t2 = Term(term='World')
        self.t2.save()
        for o in ops1:
            o.terms.add(self.t1)
        for o in ops2:
            o.terms.add(self.t2)

    def tearDown(self):
        Term.objects.all().delete()

    def test_frequent_from_opinions(self):
        """Test frequent term listing based on opinions queryset."""
        ops = Opinion.objects.no_cache()
        ts = Term.objects.frequent(ops)
        assert ts.count() > 0

    def test_frequent_by_date(self):
        """Test frequent terms by date."""
        ts = Term.objects.frequent(date_end=self.split_date)
        eq_(ts[0].term, self.t1.term)

        ts = Term.objects.frequent(date_start=self.split_date)
        eq_(ts[0].term, self.t2.term)

    def test_frequent_stats(self):
        """Test frequent terms weights."""
        ts = Term.objects.frequent()
        freq = frequent_terms(qs=ts)
        eq_(len(freq), 2)

    def test_unicode(self):
        """Term's unicode representation."""
        t = Term(term='Hello')
        eq_(unicode(t), u'Hello')

    @patch.object(settings._wrapped, 'DISABLE_TERMS', False)
    def test_term_extraction(self):
        """Make sure we create our terms."""
        settings.DISABLE_TERMS = False
        op = Opinion.objects.create(product=1, description='This is a test')
        terms = [term.term for term in op.terms.all()]
        eq_(terms, ['test'])
示例#4
0
 def setUp(self):
     self.split_date = date(2010, 6, 18)
     ops1 = Opinion.objects.no_cache().filter(
         created__lt=self.split_date)
     ops2 = Opinion.objects.no_cache().filter(
         created__gte=self.split_date)
     self.t1 = Term(term='Hello')
     self.t1.save()
     self.t2 = Term(term='World')
     self.t2.save()
     for o in ops1:
         o.terms.add(self.t1)
     for o in ops2:
         o.terms.add(self.t2)
示例#5
0
class TermTestCase(TestCase):
    fixtures = ['feedback/opinions']

    def setUp(self):
        self.split_date = date(2010, 6, 18)
        ops1 = Opinion.objects.no_cache().filter(
            created__lt=self.split_date)
        ops2 = Opinion.objects.no_cache().filter(
            created__gte=self.split_date)
        self.t1 = Term(term='Hello')
        self.t1.save()
        self.t2 = Term(term='World')
        self.t2.save()
        for o in ops1:
            o.terms.add(self.t1)
        for o in ops2:
            o.terms.add(self.t2)

    def tearDown(self):
        Term.objects.all().delete()

    def test_frequent_from_opinions(self):
        """Test frequent term listing based on opinions queryset."""
        ops = Opinion.objects.no_cache()
        ts = Term.objects.frequent(ops)
        assert ts.count() > 0

    def test_frequent_by_date(self):
        """Test frequent terms by date."""
        ts = Term.objects.frequent(date_end=self.split_date)
        eq_(ts[0].term, self.t1.term)

        ts = Term.objects.frequent(date_start=self.split_date)
        eq_(ts[0].term, self.t2.term)

    def test_frequent_stats(self):
        """Test frequent terms weights."""
        ts = Term.objects.frequent()
        freq = frequent_terms(qs=ts)
        eq_(len(freq), 2)

    def test_unicode(self):
        """Term's unicode representation."""
        t = Term(term='Hello')
        eq_(unicode(t), u'Hello')
示例#6
0
 def test_unicode(self):
     """Term's unicode representation."""
     t = Term(term='Hello')
     eq_(unicode(t), u'Hello')