Skip to content

Commit

Permalink
Test speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 committed Dec 30, 2016
1 parent 6ced704 commit a3cd27a
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 47 deletions.
7 changes: 2 additions & 5 deletions acc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def fetch_picture(self):


class TestSocialPipeline(TestCase):

def setUp(self):
responses.add(responses.GET,
'http://testing.test/testpic.jpg',
Expand Down Expand Up @@ -70,10 +69,8 @@ def test_save_picture(self):


class TestLoginPage(ClientTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.c.logout()
def setUp(self):
self.c.logout()

def test_login_page_redirect(self):
response = self.c.get('/')
Expand Down
5 changes: 3 additions & 2 deletions accounting/tests/unit/tests_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@


class TestEventManager(TestCase):
def setUp(self):
self.teacher = create_teacher()
@classmethod
def setUpTestData(cls):
cls.teacher = create_teacher()

def test_find_events_by_originator_ok(self):
originator = mixer.blend(TimelineEntry, teacher=self.teacher)
Expand Down
10 changes: 6 additions & 4 deletions crm/tests/functional/tests_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@


class TestIssueCreation(ClientTestCase):
def setUp(self):
self.customer = create_customer()
self.customer.user.set_password('Vae7peeVafi8')
self.customer.user.save()
@classmethod
def setUpTestData(cls):
cls.customer = create_customer()
cls.customer.user.set_password('Vae7peeVafi8')
cls.customer.user.save()

def setUp(self):
self.c.logout()
self.c.login(username=self.customer.user.username, password='Vae7peeVafi8')

Expand Down
7 changes: 4 additions & 3 deletions crm/tests/functional/tests_mailchimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@


class TestMailchimpExport(ClientTestCase):
def setUp(self):
self.customers = []
@classmethod
def setUpTestData(cls):
cls.customers = []
for i in range(0, 10):
self.customers.append(create_customer())
cls.customers.append(create_customer())

def test_csv_export(self):
ids = ','.join([str(customer.pk) for customer in self.customers])
Expand Down
16 changes: 9 additions & 7 deletions market/tests/AutoSchedule/tests_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@


class TestBusyPeriods(TestCase):
def setUp(self):
self.teacher = create_teacher()
@classmethod
def setUpTestData(cls):
cls.teacher = create_teacher()
mixer.blend(
'extevents.ExternalEvent',
teacher=self.teacher,
start=self.tzdatetime(2032, 12, 5, 13, 30),
end=self.tzdatetime(2032, 12, 5, 14, 30),
teacher=cls.teacher,
start=cls.tzdatetime(2032, 12, 5, 13, 30),
end=cls.tzdatetime(2032, 12, 5, 14, 30),
)

def test_from_queryset(self):
Expand Down Expand Up @@ -91,8 +92,9 @@ def test_ends_right_at_the_end_of_period(self):


class TestAutoschedule(TestCase):
def setUp(self):
self.teacher = create_teacher()
@classmethod
def setUpTestData(cls):
cls.teacher = create_teacher()

def test_init_extevents(self):
for i in range(0, 10):
Expand Down
10 changes: 5 additions & 5 deletions market/tests/SortingHat/tests_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
class SchedulingPopupTestCaseBase(ClientTestCase):
fixtures = ('lessons',)

def setUp(self):
self.customer = create_customer()
self.host = create_teacher()
mixer.blend(WorkingHours, teacher=self.host, weekday=0, start='13:00', end='15:00') # monday
@classmethod
def setUpTestData(cls):
cls.customer = create_customer()
cls.host = create_teacher()
mixer.blend(WorkingHours, teacher=cls.host, weekday=0, start='13:00', end='15:00') # monday

def _buy_a_lesson(self, lesson):
c = Class(
Expand Down Expand Up @@ -49,7 +50,6 @@ def _step2(self, just_checking=False, **kwargs):


class TestSchedulingPopupHTML(SchedulingPopupTestCaseBase):

def test_lesson_categories(self):
"""
Buy two lessons of different type and assure that filter of two types
Expand Down
6 changes: 2 additions & 4 deletions market/tests/functional/tests_customer_lesson_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

@override_settings(TIME_ZONE='UTC')
class TestCustomerLessonList(ClassIntegrationTestCase):

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

self.customer = create_customer(timezone='UTC') # avoid timezone issues during re-login
self.customer.user.set_password('hidooZohLu0e')
self.customer.user.save()

self.customer = create_customer(timezone='UTC', password='hidooZohLu0e') # avoid timezone issues during re-login
self.c.logout()
self.c.login(username=self.customer.user.username, password='hidooZohLu0e')

Expand Down
13 changes: 7 additions & 6 deletions market/tests/functional/tests_subscription_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
class TestSubscriptionStatus(TestCase):
fixtures = ('products', 'lessons')

def setUp(self):
self.customer = create_customer()
self.teacher = create_teacher(works_24x7=True)
self.subscription = Subscription(
customer=self.customer,
@classmethod
def setUpTestData(cls):
cls.customer = create_customer()
cls.teacher = create_teacher(works_24x7=True)
cls.subscription = Subscription(
customer=cls.customer,
product=Product1.objects.get(pk=1),
buy_price=150,
)

self.subscription.save()
cls.subscription.save()

def _schedule(self, c, date=None):
if date is None:
Expand Down
15 changes: 8 additions & 7 deletions market/tests/functional/tests_timeline_entry_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

@freeze_time('2032-12-01 12:00')
class TimelineEntryPopupTestCase(ClientTestCase):
def setUp(self):
self.host = create_teacher(works_24x7=True)
@classmethod
def setUpTestData(cls):
cls.host = create_teacher(works_24x7=True)

self.lesson = mixer.blend(lessons.MasterClass, host=self.host, photo=mixer.RANDOM)
cls.lesson = mixer.blend(lessons.MasterClass, host=cls.host, photo=mixer.RANDOM)

self.entry = mixer.blend(
cls.entry = mixer.blend(
TimelineEntry,
teacher=self.host,
lesson=self.lesson,
start=self.tzdatetime(2032, 12, 5, 13, 00)
teacher=cls.host,
lesson=cls.lesson,
start=cls.tzdatetime(2032, 12, 5, 13, 00)
)

def test_popup_loading_fail(self):
Expand Down
9 changes: 5 additions & 4 deletions market/tests/functional/tests_user_cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@


class UserCancellationTestCase(ClientTestCase):
def setUp(self):
self.customer = create_customer()
self.teacher = create_teacher(works_24x7=True)
self.lesson = mixer.blend(lessons.OrdinaryLesson, customer=self.customer)
@classmethod
def setUpTestData(cls):
cls.customer = create_customer()
cls.teacher = create_teacher(works_24x7=True)
cls.lesson = mixer.blend(lessons.OrdinaryLesson, customer=cls.customer)

def _buy_a_lesson(self):
c = Class(
Expand Down

0 comments on commit a3cd27a

Please sign in to comment.