Skip to content

Commit

Permalink
remove some duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
ajslater committed Feb 6, 2022
1 parent 829799e commit 984eb63
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions tests/xapian_tests/tests/test_management_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,20 @@

from ..models import BlogEntry
from ..search_indexes import BlogSearchIndex
from .test_backend import HaystackBackendTestCase
from .test_backend import HaystackBackendTestCase, BackendFeaturesTestCase


class ManagementCommandTestCase(HaystackBackendTestCase, TestCase):

NUM_BLOG_ENTRIES = 20

def get_index(self):
return BlogSearchIndex()

@staticmethod
def get_entry(i):
entry = BlogEntry()
entry.id = i
entry.author = "david%s" % i
entry.url = "http://example.com/%d/" % i
entry.boolean = bool(i % 2)
entry.number = i * 5
entry.float_number = i * 5.0
entry.decimal_number = Decimal("22.34")
entry.datetime = datetime.datetime(2009, 2, 25, 1, 1, 1) - datetime.timedelta(
seconds=i
)
entry.date = datetime.date(2009, 2, 23) + datetime.timedelta(days=i)
return entry

def setUp(self):
super().setUp()

self.sample_objs = []

for i in range(1, self.NUM_BLOG_ENTRIES + 1):
entry = self.get_entry(i)
entry = BackendFeaturesTestCase.get_entry(i)
entry.float_number = random.uniform(0.0, 1000.0)
self.sample_objs.append(entry)
entry.save()
Expand Down

0 comments on commit 984eb63

Please sign in to comment.