From 7dfa66a637f00394a18fb2f92405141c6280c48b Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Wed, 24 Jan 2018 16:25:16 +0000
Subject: [PATCH] Tidy up the fund tests

---
 opentech/apply/funds/tests/test_models.py | 38 ++++++++++-------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py
index 431676d67..e0237520c 100644
--- a/opentech/apply/funds/tests/test_models.py
+++ b/opentech/apply/funds/tests/test_models.py
@@ -13,44 +13,40 @@ def days_from_today(days):
 
 
 class TestFundModel(TestCase):
+    def setUp(self):
+        self.fund = FundTypeFactory(parent=None)
+
     def test_can_access_workflow_class(self):
-        fund = FundTypeFactory(parent=None)
-        self.assertEqual(fund.workflow, 'single')
-        self.assertEqual(fund.workflow_class, SingleStage)
+        self.assertEqual(self.fund.workflow, 'single')
+        self.assertEqual(self.fund.workflow_class, SingleStage)
 
     def test_no_open_rounds(self):
-        fund = FundTypeFactory(parent=None)
-        self.assertIsNone(fund.open_round)
+        self.assertIsNone(self.fund.open_round)
 
     def test_open_ended_round(self):
-        fund = FundTypeFactory(parent=None)
-        open_round = RoundFactory(end_date=None, parent=fund)
-        self.assertEqual(fund.open_round, open_round)
+        open_round = RoundFactory(end_date=None, parent=self.fund)
+        self.assertEqual(self.fund.open_round, open_round)
 
     def test_normal_round(self):
-        fund = FundTypeFactory(parent=None)
-        open_round = RoundFactory(parent=fund)
-        self.assertEqual(fund.open_round, open_round)
+        open_round = RoundFactory(parent=self.fund)
+        self.assertEqual(self.fund.open_round, open_round)
 
     def test_closed_round(self):
-        fund = FundTypeFactory(parent=None)
         yesterday = days_from_today(-1)
         last_week = days_from_today(-7)
-        RoundFactory(start_date=last_week, end_date=yesterday, parent=fund)
-        self.assertIsNone(fund.open_round)
+        RoundFactory(start_date=last_week, end_date=yesterday, parent=self.fund)
+        self.assertIsNone(self.fund.open_round)
 
     def test_round_not_open(self):
-        fund = FundTypeFactory(parent=None)
         tomorrow = days_from_today(1)
-        RoundFactory(start_date=tomorrow, parent=fund)
-        self.assertIsNone(fund.open_round)
+        RoundFactory(start_date=tomorrow, parent=self.fund)
+        self.assertIsNone(self.fund.open_round)
 
     def test_multiple_open_rounds(self):
-        fund = FundTypeFactory(parent=None)
-        open_round = RoundFactory(parent=fund)
+        open_round = RoundFactory(parent=self.fund)
         next_round_start = open_round.end_date + timedelta(days=1)
-        RoundFactory(start_date=next_round_start, end_date=None, parent=fund)
-        self.assertEqual(fund.open_round, open_round)
+        RoundFactory(start_date=next_round_start, end_date=None, parent=self.fund)
+        self.assertEqual(self.fund.open_round, open_round)
 
 
 class TestRoundModel(TestCase):
-- 
GitLab